diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-11 09:30:48 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-11 09:30:48 +0200 |
commit | aac2ea849e99c0a3fcbbd0e03e4e3a80bdd8a941 (patch) | |
tree | 18d35b86e066ec93341a1e4d93d296b8cc7153ad /usbmisc.c | |
parent | f5238739b42841d6e9cfd0e812adbf59a73c08b7 (diff) | |
download | usbutils-aac2ea849e99c0a3fcbbd0e03e4e3a80bdd8a941.tar.gz |
usbmisc: fix up some strncpy() issues
gcc-8 pointed out that this could be a problem. It really isn't, given
that PATH_MAX is being used, but just to make things simpler, let
strncpy() think it has a smaller buffer than it really does.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'usbmisc.c')
-rw-r--r-- | usbmisc.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -42,14 +42,14 @@ static int readlink_recursive(const char *path, char *buf, size_t bufsize) if (ret > 0) { buf[ret] = 0; if (*buf != '/') { - strncpy(temp, path, sizeof(temp)); + strncpy(temp, path, sizeof(temp) - 1); ptemp = temp + strlen(temp); while (*ptemp != '/' && ptemp != temp) ptemp--; ptemp++; - strncpy(ptemp, buf, bufsize + temp - ptemp); + strncpy(ptemp, buf, bufsize + temp - ptemp - 1); } else - strncpy(temp, buf, sizeof(temp)); + strncpy(temp, buf, sizeof(temp) - 1); return readlink_recursive(temp, buf, bufsize); } else { strncpy(buf, path, bufsize); |