Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler. Number of rules (primarily dangerous function names) in C/C++ ruleset: 223 Examining data/hidapi-0.10.0+dfsg/hidapi/hidapi.h Examining data/hidapi-0.10.0+dfsg/hidtest/test.c Examining data/hidapi-0.10.0+dfsg/libusb/hid.c Examining data/hidapi-0.10.0+dfsg/linux/hid.c Examining data/hidapi-0.10.0+dfsg/mac/hid.c Examining data/hidapi-0.10.0+dfsg/testgui/mac_support.h Examining data/hidapi-0.10.0+dfsg/testgui/test.cpp Examining data/hidapi-0.10.0+dfsg/windows/hid.c FINAL RESULTS: data/hidapi-0.10.0+dfsg/hidtest/test.c:199:2: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. system("pause"); data/hidapi-0.10.0+dfsg/libusb/hid.c:120:18: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define LOG(...) fprintf(stderr, __VA_ARGS__) data/hidapi-0.10.0+dfsg/linux/hid.c:147:2: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. vsnprintf(msg, sizeof(msg), format, args); data/hidapi-0.10.0+dfsg/mac/hid.c:312:2: [4] (buffer) wcscpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using a function version that stops copying at the end of the buffer. wcscpy(ret, s); data/hidapi-0.10.0+dfsg/testgui/test.cpp:328:2: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(str, d); data/hidapi-0.10.0+dfsg/hidtest/test.c:33:11: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char buf[256]; data/hidapi-0.10.0+dfsg/hidtest/test.c:35:2: [2] (buffer) wchar_t: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. wchar_t wstr[MAX_STR]; data/hidapi-0.10.0+dfsg/libusb/hid.c:400:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[512]; data/hidapi-0.10.0+dfsg/libusb/hid.c:405:2: [2] (buffer) wchar_t: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. wchar_t wbuf[256]; data/hidapi-0.10.0+dfsg/libusb/hid.c:489:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char str[64]; data/hidapi-0.10.0+dfsg/libusb/hid.c:628:18: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char data[256]; data/hidapi-0.10.0+dfsg/libusb/hid.c:757:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(rpt->data, transfer->buffer, transfer->actual_length); data/hidapi-0.10.0+dfsg/libusb/hid.c:1085:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(data, rpt->data, len); data/hidapi-0.10.0+dfsg/libusb/hid.c:1513:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char search_string[64]; data/hidapi-0.10.0+dfsg/linux/hid.c:146:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char msg[100]; data/hidapi-0.10.0+dfsg/linux/hid.c:668:23: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). dev->device_handle = open(path, O_RDWR); data/hidapi-0.10.0+dfsg/mac/hid.c:437:2: [2] (buffer) wchar_t: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. wchar_t buf[BUF_LEN]; data/hidapi-0.10.0+dfsg/mac/hid.c:707:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(rpt->data, report, report_length); data/hidapi-0.10.0+dfsg/mac/hid.c:851:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char str[32]; data/hidapi-0.10.0+dfsg/mac/hid.c:859:3: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(str, "HIDAPI_%p", (void*) dev->device_handle); data/hidapi-0.10.0+dfsg/mac/hid.c:970:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(data, rpt->data, len); data/hidapi-0.10.0+dfsg/mac/hid.c:1266:3: [2] (buffer) wchar_t: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. wchar_t serial[256], buf[256]; data/hidapi-0.10.0+dfsg/mac/hid.c:1267:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char cbuf[256]; data/hidapi-0.10.0+dfsg/testgui/test.cpp:375:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[256]; data/hidapi-0.10.0+dfsg/testgui/test.cpp:406:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[256]; data/hidapi-0.10.0+dfsg/testgui/test.cpp:437:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[256]; data/hidapi-0.10.0+dfsg/testgui/test.cpp:482:11: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char buf[256]; data/hidapi-0.10.0+dfsg/windows/hid.c:379:4: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char driver_name[256]; data/hidapi-0.10.0+dfsg/windows/hid.c:432:4: [2] (buffer) wchar_t: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. wchar_t wstr[WSTR_LEN]; /* TODO: Determine Size */ data/hidapi-0.10.0+dfsg/windows/hid.c:678:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(buf, data, length); data/hidapi-0.10.0+dfsg/windows/hid.c:783:4: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(data, dev->read_buf+1, copy_len); data/hidapi-0.10.0+dfsg/windows/hid.c:788:4: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(data, dev->read_buf, copy_len); data/hidapi-0.10.0+dfsg/windows/hid.c:1019:11: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char buf[65]; data/hidapi-0.10.0+dfsg/windows/hid.c:1031:15: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int handle = open(VendorID, ProductID, L"12345"); data/hidapi-0.10.0+dfsg/hidtest/test.c:183:3: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(500*1000); data/hidapi-0.10.0+dfsg/libusb/hid.c:1350:3: [1] (buffer) wcsncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). wcsncpy(string, str, maxlen); data/hidapi-0.10.0+dfsg/libusb/hid.c:1523:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(search_string, locale, sizeof(search_string)); data/hidapi-0.10.0+dfsg/linux/hid.c:325:7: [1] (buffer) wcsncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant character. wcsncpy(string, L"", maxlen); data/hidapi-0.10.0+dfsg/linux/hid.c:760:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). bytes_read = read(dev->device_handle, data, length); data/hidapi-0.10.0+dfsg/mac/hid.c:310:15: [1] (buffer) wcslen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). size_t len = wcslen(s); data/hidapi-0.10.0+dfsg/testgui/test.cpp:326:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). size_t sz = strlen(d); data/hidapi-0.10.0+dfsg/windows/hid.c:461:11: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). len = strlen(str); data/hidapi-0.10.0+dfsg/windows/hid.c:463:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(cur_dev->path, str, len+1); data/hidapi-0.10.0+dfsg/windows/hid.c:1049:2: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(handle, buf, 65); ANALYSIS SUMMARY: Hits = 44 Lines analyzed = 6034 in approximately 1.01 seconds (5953 lines/second) Physical Source Lines of Code (SLOC) = 3939 Hits@level = [0] 48 [1] 10 [2] 29 [3] 0 [4] 5 [5] 0 Hits@level+ = [0+] 92 [1+] 44 [2+] 34 [3+] 5 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 23.3562 [1+] 11.1703 [2+] 8.63163 [3+] 1.26936 [4+] 1.26936 [5+] 0 Dot directories skipped = 2 (--followdotdir overrides) Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.