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/python-hidapi-0.9.0.post3/hidapi/hidapi/hidapi.h Examining data/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c Examining data/python-hidapi-0.9.0.post3/hidapi/linux/hid.c Examining data/python-hidapi-0.9.0.post3/hidapi/mac/hid.c Examining data/python-hidapi-0.9.0.post3/hidapi/windows/hid.c FINAL RESULTS: data/python-hidapi-0.9.0.post3/hidapi/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/python-hidapi-0.9.0.post3/hidapi/linux/hid.c:141: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/python-hidapi-0.9.0.post3/hidapi/mac/hid.c:300: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/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c:394: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/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c:399: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/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c:483: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/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c:613: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/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c:742: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/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c:1068: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/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c:1496: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/python-hidapi-0.9.0.post3/hidapi/linux/hid.c:140: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/python-hidapi-0.9.0.post3/hidapi/linux/hid.c:652: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/python-hidapi-0.9.0.post3/hidapi/mac/hid.c:414: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/python-hidapi-0.9.0.post3/hidapi/mac/hid.c:678: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/python-hidapi-0.9.0.post3/hidapi/mac/hid.c:822: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/python-hidapi-0.9.0.post3/hidapi/mac/hid.c:830: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/python-hidapi-0.9.0.post3/hidapi/mac/hid.c:941: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/python-hidapi-0.9.0.post3/hidapi/mac/hid.c:1223: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/python-hidapi-0.9.0.post3/hidapi/mac/hid.c:1224: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:352: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:406: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:652: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:739: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:744: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:975: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:987: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/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c:1333: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/python-hidapi-0.9.0.post3/hidapi/libusb/hid.c:1506: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/python-hidapi-0.9.0.post3/hidapi/linux/hid.c:319: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/python-hidapi-0.9.0.post3/hidapi/linux/hid.c:744: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/python-hidapi-0.9.0.post3/hidapi/mac/hid.c:298: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:435: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:437: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/python-hidapi-0.9.0.post3/hidapi/windows/hid.c:1005: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 = 34 Lines analyzed = 5110 in approximately 0.15 seconds (33395 lines/second) Physical Source Lines of Code (SLOC) = 3283 Hits@level = [0] 13 [1] 8 [2] 23 [3] 0 [4] 3 [5] 0 Hits@level+ = [0+] 47 [1+] 34 [2+] 26 [3+] 3 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 14.3162 [1+] 10.3564 [2+] 7.91959 [3+] 0.913798 [4+] 0.913798 [5+] 0 Dot directories skipped = 1 (--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.