diff options
author | Pete Batard <pbatard@gmail.com> | 2010-08-01 22:09:29 +0100 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-08-01 22:09:29 +0100 |
commit | 8c3473b0ca16819b6aa9f35af15cf98ebd74058b (patch) | |
tree | f6100d84341676f77346d73233141af3fab2edca | |
parent | 48ce4304c8b04fc13f122655d70eb5b1fa3c209d (diff) | |
download | libusb-8c3473b0ca16819b6aa9f35af15cf98ebd74058b.tar.gz |
fixed mishandling of null terminators in safe_strncpy()
-rw-r--r-- | libusb/os/windows_usb.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h index 8639b70..f8fcebc 100644 --- a/libusb/os/windows_usb.h +++ b/libusb/os/windows_usb.h @@ -67,7 +67,7 @@ extern char *_strdup(const char *strSource); #endif #define safe_free(p) do {if (p != NULL) {free(p); p = NULL;}} while(0) #define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0) -#define safe_strncpy(dst, dst_max, src, count) strncpy(dst, src, min(count, dst_max - 1)) +#define safe_strncpy(dst, dst_max, src, count) do {strncpy(dst, src, dst_max); ((char*)dst)[dst_max-1] = 0;} while(0) #define safe_strcpy(dst, dst_max, src) safe_strncpy(dst, dst_max, src, strlen(src)+1) #define safe_strncat(dst, dst_max, src, count) strncat(dst, src, min(count, dst_max - strlen(dst) - 1)) #define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, strlen(src)+1) |