summaryrefslogtreecommitdiff
path: root/usbmisc.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-11 09:30:48 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-11 09:30:48 +0200
commitaac2ea849e99c0a3fcbbd0e03e4e3a80bdd8a941 (patch)
tree18d35b86e066ec93341a1e4d93d296b8cc7153ad /usbmisc.c
parentf5238739b42841d6e9cfd0e812adbf59a73c08b7 (diff)
downloadusbutils-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.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usbmisc.c b/usbmisc.c
index d4bbe67..cef6ec8 100644
--- a/usbmisc.c
+++ b/usbmisc.c
@@ -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);