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/wpan-tools-0.9/examples/af_ieee802154_rx.c Examining data/wpan-tools-0.9/examples/af_ieee802154_tx.c Examining data/wpan-tools-0.9/examples/af_inet6_rx.c Examining data/wpan-tools-0.9/examples/af_inet6_tx.c Examining data/wpan-tools-0.9/examples/af_packet_rx.c Examining data/wpan-tools-0.9/examples/af_packet_tx.c Examining data/wpan-tools-0.9/src/info.c Examining data/wpan-tools-0.9/src/interface.c Examining data/wpan-tools-0.9/src/iwpan.c Examining data/wpan-tools-0.9/src/iwpan.h Examining data/wpan-tools-0.9/src/mac.c Examining data/wpan-tools-0.9/src/nl802154.h Examining data/wpan-tools-0.9/src/nl_extras.h Examining data/wpan-tools-0.9/src/phy.c Examining data/wpan-tools-0.9/src/sections.c Examining data/wpan-tools-0.9/wpan-hwsim/mac802154_hwsim.h Examining data/wpan-tools-0.9/wpan-hwsim/wpan-hwsim.c Examining data/wpan-tools-0.9/wpan-ping/wpan-ping.c FINAL RESULTS: data/wpan-tools-0.9/src/info.c:156:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cca_mode_buf,"(%d) %s", cca_mode, "Energy above threshold"); data/wpan-tools-0.9/src/info.c:159:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cca_mode_buf,"(%d) %s", cca_mode, "Carrier sense only"); data/wpan-tools-0.9/src/info.c:164:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cca_mode_buf, "(%d, cca_opt: %d) %s", cca_mode, cca_opt, data/wpan-tools-0.9/src/info.c:168:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cca_mode_buf, "(%d, cca_opt: %d) %s", cca_mode, cca_opt, data/wpan-tools-0.9/src/info.c:178:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cca_mode_buf,"(%d) %s", cca_mode, "ALOHA"); data/wpan-tools-0.9/src/info.c:181:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cca_mode_buf,"(%d) %s", cca_mode, data/wpan-tools-0.9/src/info.c:185:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cca_mode_buf,"(%d) %s", cca_mode, data/wpan-tools-0.9/wpan-hwsim/wpan-hwsim.c:401:7: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. c = getopt_long(argc, (char **)argv, "vhdi:", data/wpan-tools-0.9/wpan-ping/wpan-ping.c:507:7: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. c = getopt_long(argc, argv, "a:ec:s:i:dvhI:", perf_long_opts, &opt_idx); data/wpan-tools-0.9/wpan-ping/wpan-ping.c:509:7: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. c = getopt(argc, argv, "a:ec:s:i:dvhI:"); data/wpan-tools-0.9/examples/af_ieee802154_rx.c:57: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[MAX_PACKET_LEN + 1]; data/wpan-tools-0.9/examples/af_ieee802154_rx.c:77: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(&src.addr.hwaddr, &long_addr, IEEE802154_ADDR_LEN); data/wpan-tools-0.9/examples/af_ieee802154_tx.c:58: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[MAX_PACKET_LEN + 1]; data/wpan-tools-0.9/examples/af_ieee802154_tx.c:77: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(&dst.addr.hwaddr, long_addr, IEEE802154_ADDR_LEN); data/wpan-tools-0.9/examples/af_ieee802154_tx.c:83:2: [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(buf, "Hello world from IEEE 802.15.4 socket example!"); data/wpan-tools-0.9/examples/af_inet6_rx.c:36: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[MAX_PACKET_LEN + 1]; data/wpan-tools-0.9/examples/af_inet6_rx.c:38: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 ipv6[INET6_ADDRSTRLEN]; data/wpan-tools-0.9/examples/af_inet6_tx.c:38: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[MAX_PACKET_LEN + 1]; data/wpan-tools-0.9/examples/af_inet6_tx.c:63:2: [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(buf, "Hello world from AF_INET6 socket example!"); data/wpan-tools-0.9/examples/af_packet_rx.c:45: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[MAX_PACKET_LEN + 1]; data/wpan-tools-0.9/examples/af_packet_tx.c:45: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[MAX_PACKET_LEN + 1]; data/wpan-tools-0.9/src/info.c:149:8: [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. static char cca_mode_buf[100]; data/wpan-tools-0.9/src/info.c:172:4: [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(cca_mode_buf, "Unknown CCA option (%d) for CCA mode (%d)", data/wpan-tools-0.9/src/info.c:189: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(cca_mode_buf, "Unknown CCA mode (%d)", cca_mode); data/wpan-tools-0.9/src/info.c:195:14: [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. static const char *commands[NL802154_CMD_MAX + 1] = { data/wpan-tools-0.9/src/info.c:218:8: [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. static char cmdbuf[100]; data/wpan-tools-0.9/src/info.c:225:2: [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(cmdbuf, "Unknown command (%d)", cmd); data/wpan-tools-0.9/src/interface.c:19:8: [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. static char iftypebuf[100]; data/wpan-tools-0.9/src/interface.c:31: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(iftypebuf, "Invalid iftype (%d)", iftype); data/wpan-tools-0.9/src/iwpan.c:223: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[200]; data/wpan-tools-0.9/src/iwpan.c:228:7: [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). fd = open(buf, O_RDONLY); data/wpan-tools-0.9/src/iwpan.c:238:9: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). return atoi(buf); data/wpan-tools-0.9/src/phy.c:157: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 pathbuf[MAXPATHLEN]; data/wpan-tools-0.9/src/phy.c:167:9: [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). return open(path, O_RDONLY); data/wpan-tools-0.9/wpan-ping/wpan-ping.c:182: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(&conf->src.addr.hwaddr, &temp, IEEE802154_ADDR_LEN); data/wpan-tools-0.9/wpan-ping/wpan-ping.c:230:26: [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. static int print_address(char *addr, uint8_t dst_extended[IEEE802154_ADDR_LEN]) data/wpan-tools-0.9/wpan-ping/wpan-ping.c:268: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 addr[24]; data/wpan-tools-0.9/wpan-ping/wpan-ping.c:524:20: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). conf->packets = atoi(optarg); data/wpan-tools-0.9/wpan-ping/wpan-ping.c:527:23: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). conf->packet_len = atoi(optarg); data/wpan-tools-0.9/wpan-ping/wpan-ping.c:539:21: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). conf->interval = atoi(optarg); data/wpan-tools-0.9/examples/af_ieee802154_tx.c:87:24: [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 = sendto(sd, buf, strlen(buf), 0, (struct sockaddr *)&dst, sizeof(dst)); data/wpan-tools-0.9/examples/af_inet6_tx.c:67:24: [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). ret = sendto(sd, buf, strlen(buf), 0, (struct sockaddr *)&dst, sizeof(dst)); data/wpan-tools-0.9/examples/af_packet_rx.c:57:2: [1] (buffer) strncpy: 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 string. strncpy(ifr.ifr_name, "monitor0", IFNAMSIZ); data/wpan-tools-0.9/examples/af_packet_tx.c:56:2: [1] (buffer) strncpy: 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 string. strncpy(ifr.ifr_name, "wpan0", IFNAMSIZ); data/wpan-tools-0.9/src/iwpan.c:130:6: [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). if (strlen(indent)) data/wpan-tools-0.9/src/iwpan.c:231:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). pos = read(fd, buf, sizeof(buf) - 1); data/wpan-tools-0.9/src/iwpan.c:500:7: [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). if (strlen(*argv) == 3) { data/wpan-tools-0.9/wpan-ping/wpan-ping.c:253: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(sleep_usec); ANALYSIS SUMMARY: Hits = 48 Lines analyzed = 4091 in approximately 0.14 seconds (28779 lines/second) Physical Source Lines of Code (SLOC) = 3080 Hits@level = [0] 192 [1] 8 [2] 30 [3] 3 [4] 7 [5] 0 Hits@level+ = [0+] 240 [1+] 48 [2+] 40 [3+] 10 [4+] 7 [5+] 0 Hits/KSLOC@level+ = [0+] 77.9221 [1+] 15.5844 [2+] 12.987 [3+] 3.24675 [4+] 2.27273 [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.