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/sntop-1.4.3/getopt_long.c Examining data/sntop-1.4.3/getopt_long.h Examining data/sntop-1.4.3/sntop.c Examining data/sntop-1.4.3/sntop.h FINAL RESULTS: data/sntop-1.4.3/sntop.c:117:5: [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(ping, PING_LINE); data/sntop-1.4.3/sntop.c:143:5: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf("\r" SNTOP_VERSION); data/sntop-1.4.3/sntop.c:180:3: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(SNTOP_VERSION " - loading ... "); data/sntop-1.4.3/sntop.c:215:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "%s %s %s", ping, current->host, PING_END); data/sntop-1.4.3/getopt_long.c:85:5: [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. int getopt_long (int argc, char *const *argv, const char *optstring, data/sntop-1.4.3/getopt_long.h:31:12: [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. extern int getopt_long (int argc, char *const *argv, const char *shortopts, data/sntop-1.4.3/sntop.c:102:36: [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. snprintf(cfile, CONF_BUF, "%s%s", getenv("HOME"), CONF_UFILE); data/sntop-1.4.3/sntop.c:104:13: [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. while((i = getopt_long(argc, argv, "docpwse:f:r:vhb:a:l:", longopts, (int *) 0)) != -1) { data/sntop-1.4.3/getopt_long.c:70: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 ((char *) &argv[first_nonopt], (char *) temp, nonopts_size); data/sntop-1.4.3/getopt_long.c:71: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 ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt], data/sntop-1.4.3/getopt_long.c:73: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 ((char *) temp, data/sntop-1.4.3/sntop.c:64: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[IN_BUF + PING_BUF + PEND_BUF]; data/sntop-1.4.3/sntop.c:65: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 cfile[CONF_BUF]; data/sntop-1.4.3/sntop.c:66: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 hfile[CONF_BUF] = HTML_FILE; data/sntop-1.4.3/sntop.c:68: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 ping[PING_BUF + 1] = FPING_LINE; data/sntop-1.4.3/sntop.c:69: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 action[ACTION_BUF]; data/sntop-1.4.3/sntop.c:132:15: [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). refresh = atoi(optarg); data/sntop-1.4.3/sntop.c:148:53: [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). snprintf(ping, PING_BUF, "fping -r 1 -b %d -q", atoi(optarg)); data/sntop-1.4.3/sntop.c:340: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 * argv[4]; data/sntop-1.4.3/sntop.c:358: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 *field[3]; data/sntop-1.4.3/sntop.c:359: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[IN_BUF]; data/sntop-1.4.3/sntop.c:365:12: [2] (misc) fopen: 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). if ((cf = fopen(cfile, "r")) == NULL) { data/sntop-1.4.3/sntop.c:368:13: [2] (misc) fopen: 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). if ((cf = fopen(cfile, "r")) == NULL) data/sntop-1.4.3/sntop.c:412: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 *argv[5]; data/sntop-1.4.3/sntop.c:424:15: [2] (misc) fopen: 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). if (((*hf) = fopen(file, "w")) == NULL) data/sntop-1.4.3/sntop.c:448: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. extern char *tzname[2]; data/sntop-1.4.3/sntop.h:44:6: [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[IN_BUF]; data/sntop-1.4.3/sntop.h:45:6: [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 host[IN_BUF]; data/sntop-1.4.3/sntop.h:46:6: [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 note[IN_BUF]; data/sntop-1.4.3/getopt_long.c:207:26: [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 (s - nextchar == strlen (p->name)) data/sntop-1.4.3/getopt_long.c:231:16: [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). nextchar += strlen (nextchar); data/sntop-1.4.3/getopt_long.c:261:17: [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). nextchar += strlen (nextchar); data/sntop-1.4.3/getopt_long.c:274:17: [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). nextchar += strlen (nextchar); data/sntop-1.4.3/getopt_long.c:278:16: [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). nextchar += strlen (nextchar); data/sntop-1.4.3/sntop.c:126:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(hfile, optarg, CONF_BUF); data/sntop-1.4.3/sntop.c:129:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(cfile, optarg, CONF_BUF); data/sntop-1.4.3/sntop.c:136:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(action, optarg, ACTION_BUF); data/sntop-1.4.3/sntop.c:140:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(action, optarg, ACTION_BUF); data/sntop-1.4.3/sntop.c:256:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(0, &ch, 1) != 1) data/sntop-1.4.3/sntop.c:301:24: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while(--n > 0 && (c = getc(f)) != EOF && (*cs++ = c) != d && c != '#') ; data/sntop-1.4.3/sntop.c:311:36: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (c != '\n' && c != EOF) c = getc(f); /* clear the line */ data/sntop-1.4.3/sntop.c:367:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(cfile, CONF_SFILE, CONF_BUF); data/sntop-1.4.3/sntop.c:398:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(field[i++], buf, IN_BUF); ANALYSIS SUMMARY: Hits = 43 Lines analyzed = 941 in approximately 0.05 seconds (19418 lines/second) Physical Source Lines of Code (SLOC) = 680 Hits@level = [0] 37 [1] 14 [2] 21 [3] 4 [4] 4 [5] 0 Hits@level+ = [0+] 80 [1+] 43 [2+] 29 [3+] 8 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 117.647 [1+] 63.2353 [2+] 42.6471 [3+] 11.7647 [4+] 5.88235 [5+] 0 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.