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/nmrpflash-0.9.14-16-ge95526d/ethsock.c Examining data/nmrpflash-0.9.14-16-ge95526d/nmrpd.h Examining data/nmrpflash-0.9.14-16-ge95526d/tftp.c Examining data/nmrpflash-0.9.14-16-ge95526d/util.c Examining data/nmrpflash-0.9.14-16-ge95526d/main.c Examining data/nmrpflash-0.9.14-16-ge95526d/nmrp.c FINAL RESULTS: data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:110:8: [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. ret = vsnprintf(cmd, sizeof(cmd) - 1, fmt, va); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:115:8: [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. ret = system(cmd); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:448:13: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. } else if (sscanf(intf, NMRPFLASH_NETALIAS_PREFIX "%u", &dev_num) != 1) { data/nmrpflash-0.9.14-16-ge95526d/main.c:177:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(newpath, "%s;%s\\Sysnative", oldpath, windir); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:416:59: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (args->file_local && strcmp(args->file_local, "-") && access(args->file_local, R_OK) == -1) { data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:609:15: [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. status = system(args->tftpcmd); data/nmrpflash-0.9.14-16-ge95526d/tftp.c:74: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(pkt, opt); data/nmrpflash-0.9.14-16-ge95526d/tftp.c:76: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(pkt, val); data/nmrpflash-0.9.14-16-ge95526d/util.c:57:2: [4] (format) snprintf: 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. snprintf(buf, sizeof(buf) - 1, (base == 16 ? "%llx" : (base == 8 ? "%llo" : "%lld")), ll); data/nmrpflash-0.9.14-16-ge95526d/main.c:173:12: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. oldpath = getenv("PATH"); data/nmrpflash-0.9.14-16-ge95526d/main.c:174:11: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. windir = getenv("WINDIR"); data/nmrpflash-0.9.14-16-ge95526d/main.c:186:14: [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. while ((c = getopt(argc, argv, "a:A:Bc:f:F:i:m:M:p:R:t:T:hLVvU")) != -1) { data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:85:9: [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 buf[18]; data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:93: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 errbuf[PCAP_ERRBUF_SIZE]; data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:105: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 cmd[1024]; data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:140: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(hwaddr, src, 6); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:147: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 name[256]; data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:149: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(name, O_RDWR, 0644); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:264: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(&arp.arp_ha.sa_data, hwaddr, 6); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:423:6: [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(hwaddr, adapter->Address, 6); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:442:9: [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 buf[128]; data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:480:9: [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 buf[512]; data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:528: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[PCAP_ERRBUF_SIZE]; data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:685: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(buf, capbuf, MIN(len, hdr->caplen)); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:755: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(arp.bPhysAddr, hwaddr, 6); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:782: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((*undo)->hwaddr, hwaddr, 6); data/nmrpflash-0.9.14-16-ge95526d/main.c:229:11: [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). val = atoi(optarg); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:67: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 val[1]; data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:75: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 opts[44]; data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:86:9: [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 buf[16]; data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:160:9: [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 buf[256]; data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:165: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, p, len); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:197: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(opt->val, val, len); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:476: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(tx.eh.ether_shost, src, 6); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:477: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(tx.eh.ether_dhost, dest, 6); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:519:6: [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(rx.eh.ether_shost, dest, 6); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:531: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(tx.eh.ether_dhost, rx.eh.ether_shost, 6); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:702:5: [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(rx.eh.ether_shost, tx.eh.ether_dhost, 6); data/nmrpflash-0.9.14-16-ge95526d/tftp.c:316: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 rx[2048], tx[2048]; data/nmrpflash-0.9.14-16-ge95526d/tftp.c:337:8: [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(args->file_local, O_RDONLY | O_BINARY); data/nmrpflash-0.9.14-16-ge95526d/util.c:56:9: [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 buf[32]; data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:160:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(fd, &c, 1) != 1) { data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:462:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buf, dev->name, sizeof(buf) - 1); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:972:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ifr.ifr_name, intf, IFNAMSIZ); data/nmrpflash-0.9.14-16-ge95526d/ethsock.c:1031:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ifra.ifra_name, sock->intf, IFNAMSIZ); data/nmrpflash-0.9.14-16-ge95526d/main.c:176:20: [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). newpath = malloc(strlen(oldpath) + strlen(windir) + 32); data/nmrpflash-0.9.14-16-ge95526d/main.c:176:38: [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). newpath = malloc(strlen(oldpath) + strlen(windir) + 32); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:212:52: [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). msg_mkopt(msg, msg->opts, NMRP_O_MAGIC_NO, magic, strlen(magic)); data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:235:38: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). #define ethsock_recv(sock, buf, len) read(STDIN_FILENO, buf, len) data/nmrpflash-0.9.14-16-ge95526d/nmrp.c:295: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). if (i == strlen(str)) { data/nmrpflash-0.9.14-16-ge95526d/tftp.c:75:9: [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). pkt += strlen(opt) + 1; data/nmrpflash-0.9.14-16-ge95526d/tftp.c:77:9: [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). pkt += strlen(val) + 1; data/nmrpflash-0.9.14-16-ge95526d/tftp.c:165:47: [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). fprintf(fp, "(%s, %s)", pkt + 2, pkt + 2 + strlen(pkt + 2) + 1); data/nmrpflash-0.9.14-16-ge95526d/tftp.c:251: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). len = 4 + strlen(pkt + 4); data/nmrpflash-0.9.14-16-ge95526d/tftp.c:305:9: [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). return strlen(filename) <= 255 && is_netascii(filename); data/nmrpflash-0.9.14-16-ge95526d/tftp.c:427:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). len = read(fd, tx + 4, blksize); ANALYSIS SUMMARY: Hits = 56 Lines analyzed = 2897 in approximately 0.09 seconds (31680 lines/second) Physical Source Lines of Code (SLOC) = 2335 Hits@level = [0] 118 [1] 15 [2] 29 [3] 3 [4] 9 [5] 0 Hits@level+ = [0+] 174 [1+] 56 [2+] 41 [3+] 12 [4+] 9 [5+] 0 Hits/KSLOC@level+ = [0+] 74.5182 [1+] 23.9829 [2+] 17.5589 [3+] 5.13919 [4+] 3.85439 [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.