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/netkit-tftp-0.17/tftp/main.c Examining data/netkit-tftp-0.17/tftp/tftpsubs.c Examining data/netkit-tftp-0.17/tftp/tftpsubs.h Examining data/netkit-tftp-0.17/tftp/tftp.c Examining data/netkit-tftp-0.17/version.h Examining data/netkit-tftp-0.17/include/arpa/tftp.h Examining data/netkit-tftp-0.17/tftpd/tftpd.c FINAL RESULTS: data/netkit-tftp-0.17/tftp/main.c:338: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(mode, newmode); data/netkit-tftp-0.17/tftp/main.c:438:3: [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(ccp, tail(argv[n])); data/netkit-tftp-0.17/tftp/tftp.c:376: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(ackbuf + ((char*)tp->th_msg - (char*)tp), pe->e_msg); data/netkit-tftp-0.17/tftpd/tftpd.c:624: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(buf + ((char*)&tp->th_msg - (char*)tp), pe->e_msg); data/netkit-tftp-0.17/tftpd/tftpd.c:115:15: [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 ((ch = getopt(ac, av, "ns")) != EOF) { data/netkit-tftp-0.17/include/arpa/tftp.h:61: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 tu_stuff[1]; /* request packet stuff */ data/netkit-tftp-0.17/include/arpa/tftp.h:63: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 th_data[1]; /* data or error string */ data/netkit-tftp-0.17/tftp/main.c:84: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 service[NI_MAXSERV] = "tftp"; data/netkit-tftp-0.17/tftp/main.c:85: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 mode[32]; data/netkit-tftp-0.17/tftp/main.c:86: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 line[200]; data/netkit-tftp-0.17/tftp/main.c:88: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 *margv[20]; data/netkit-tftp-0.17/tftp/main.c:187:2: [2] (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). Risk is low because the source is a constant string. strcpy(mode, "netascii"); data/netkit-tftp-0.17/tftp/main.c:199: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 hostname[NI_MAXHOST]; data/netkit-tftp-0.17/tftp/main.c:208:3: [2] (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). Risk is low because the source is a constant string. strcpy(line, "Connect "); data/netkit-tftp-0.17/tftp/main.c:262: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(&s_inn, ai->ai_addr, ai->ai_addrlen); data/netkit-tftp-0.17/tftp/main.c:356:3: [2] (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). Risk is low because the source is a constant string. strcpy(line, "send "); data/netkit-tftp-0.17/tftp/main.c:406: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(&s_inn, ai->ai_addr, ai->ai_addrlen); data/netkit-tftp-0.17/tftp/main.c:420: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(ccp, O_RDONLY); data/netkit-tftp-0.17/tftp/main.c:439: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(argv[n], O_RDONLY); data/netkit-tftp-0.17/tftp/main.c:472:3: [2] (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). Risk is low because the source is a constant string. strcpy(line, "get "); data/netkit-tftp-0.17/tftp/main.c:526: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(&s_inn, ai->ai_addr, ai->ai_addrlen); data/netkit-tftp-0.17/tftp/main.c:579:3: [2] (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). Risk is low because the source is a constant string. strcpy(line, "Rexmt-timeout "); data/netkit-tftp-0.17/tftp/main.c:591:6: [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). t = atoi(argv[1]); data/netkit-tftp-0.17/tftp/main.c:605:3: [2] (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). Risk is low because the source is a constant string. strcpy(line, "Maximum-timeout "); data/netkit-tftp-0.17/tftp/main.c:617:6: [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). t = atoi(argv[1]); data/netkit-tftp-0.17/tftp/tftp.c:78: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 ackbuf[PKTSIZE]; data/netkit-tftp-0.17/tftp/tftp.c:328: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(cp, name, len); data/netkit-tftp-0.17/tftp/tftp.c:332: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(cp, mode, len); data/netkit-tftp-0.17/tftp/tftpsubs.c:72: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[PKTSIZE]; /* room for data packet */ data/netkit-tftp-0.17/tftp/tftpsubs.c:257: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 rbuf[PKTSIZE]; data/netkit-tftp-0.17/tftpd/tftpd.c:90: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 buf[PKTSIZE]; data/netkit-tftp-0.17/tftpd/tftpd.c:91: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 ackbuf[PKTSIZE]; data/netkit-tftp-0.17/tftpd/tftpd.c:412: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(filename, mode == RRQ ? O_RDONLY : O_WRONLY|O_TRUNC|O_CREAT, 0600); data/netkit-tftp-0.17/tftp/main.c:210: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). len = strlen(line); data/netkit-tftp-0.17/tftp/main.c:232:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(service, argv[2], sizeof(service)); data/netkit-tftp-0.17/tftp/main.c:265:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(hostname, aiptr->ai_canonname, sizeof(hostname)); data/netkit-tftp-0.17/tftp/main.c:358: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). len = strlen(line); data/netkit-tftp-0.17/tftp/main.c:409:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(hostname, aiptr->ai_canonname, sizeof(hostname)); data/netkit-tftp-0.17/tftp/main.c:435:13: [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). ccp = targ+strlen(targ); data/netkit-tftp-0.17/tftp/main.c:474: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). len = strlen(line); data/netkit-tftp-0.17/tftp/main.c:529:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(hostname, aiptr->ai_canonname, data/netkit-tftp-0.17/tftp/main.c:581: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). len = strlen(line); data/netkit-tftp-0.17/tftp/main.c:607: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). len = strlen(line); data/netkit-tftp-0.17/tftp/tftp.c:327:8: [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(name); data/netkit-tftp-0.17/tftp/tftp.c:331:8: [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(mode); data/netkit-tftp-0.17/tftp/tftp.c:377: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). length = strlen(pe->e_msg) + 4; data/netkit-tftp-0.17/tftp/tftp.c:404:13: [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). cp = cp + strlen(cp); data/netkit-tftp-0.17/tftp/tftpsubs.c:148:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). b->counter = read(fileno(file), dp->th_data, SEGSIZE); data/netkit-tftp-0.17/tftp/tftpsubs.c:161:8: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = getc(file); data/netkit-tftp-0.17/tftpd/tftpd.c:361:33: [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 (strncmp(filename, *dirp, strlen(*dirp)) == 0) data/netkit-tftp-0.17/tftpd/tftpd.c:625: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). length = strlen(pe->e_msg); ANALYSIS SUMMARY: Hits = 51 Lines analyzed = 2278 in approximately 0.08 seconds (27797 lines/second) Physical Source Lines of Code (SLOC) = 1663 Hits@level = [0] 88 [1] 18 [2] 28 [3] 1 [4] 4 [5] 0 Hits@level+ = [0+] 139 [1+] 51 [2+] 33 [3+] 5 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 83.5839 [1+] 30.6675 [2+] 19.8437 [3+] 3.00661 [4+] 2.40529 [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.