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/daemonlogger-1.2.1/daemonlogger.c FINAL RESULTS: data/daemonlogger-1.2.1/daemonlogger.c:268:5: [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(buf, STDBUF, format, ap); data/daemonlogger-1.2.1/daemonlogger.c:291:5: [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(buf, STDBUF, format, ap); data/daemonlogger-1.2.1/daemonlogger.c:314:32: [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(!S_ISDIR(st.st_mode) || access(path, W_OK) == -1) data/daemonlogger-1.2.1/daemonlogger.c:776:8: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if(chroot(absdir) < 0) data/daemonlogger-1.2.1/daemonlogger.c:1154:17: [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(argc, argv, data/daemonlogger-1.2.1/daemonlogger.c:231: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 logdir[STDBUF]; data/daemonlogger-1.2.1/daemonlogger.c:232: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 testpath[STDBUF]; data/daemonlogger-1.2.1/daemonlogger.c:264:5: [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[STDBUF+1]; data/daemonlogger-1.2.1/daemonlogger.c:287:5: [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[STDBUF+1]; data/daemonlogger-1.2.1/daemonlogger.c:323:5: [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 filepath[STDBUF]; data/daemonlogger-1.2.1/daemonlogger.c:326:5: [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 pid_buffer[12]; data/daemonlogger-1.2.1/daemonlogger.c:350:14: [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). if((fd = open(filepath, O_CREAT | O_WRONLY, data/daemonlogger-1.2.1/daemonlogger.c:401: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). if ((fd = open("/dev/null", O_RDWR)) >= 0) data/daemonlogger-1.2.1/daemonlogger.c:526:5: [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 fpath[STDBUF+1]; data/daemonlogger-1.2.1/daemonlogger.c:803:5: [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 errorbuf[PCAP_ERRBUF_SIZE]; /* buffer to put error strings in */ data/daemonlogger-1.2.1/daemonlogger.c:925:14: [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). if((fd = open(filename, O_RDONLY)) < 0) data/daemonlogger-1.2.1/daemonlogger.c:1160:25: [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). count = atoi(optarg); data/daemonlogger-1.2.1/daemonlogger.c:1187:28: [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). maxfiles = atoi(optarg); data/daemonlogger-1.2.1/daemonlogger.c:1191:26: [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). maxpct = atoi(optarg); data/daemonlogger-1.2.1/daemonlogger.c:1259:27: [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). snaplen = atoi(optarg); data/daemonlogger-1.2.1/daemonlogger.c:1264:33: [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). rollover = atoi(optarg); data/daemonlogger-1.2.1/daemonlogger.c:378:27: [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). write(fd, pid_buffer, strlen(pid_buffer)); data/daemonlogger-1.2.1/daemonlogger.c:773: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). abslen = strlen(absdir); data/daemonlogger-1.2.1/daemonlogger.c:935:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if((readbytes = read(fd, filebuf, (int) buf.st_size)) < 0) data/daemonlogger-1.2.1/daemonlogger.c:1062: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). len += strlen(*p++) + 1; data/daemonlogger-1.2.1/daemonlogger.c:1218:40: [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(isdigit((int)optarg[strlen(optarg)-1])) data/daemonlogger-1.2.1/daemonlogger.c:1262:40: [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(isdigit((int)optarg[strlen(optarg)-1])) ANALYSIS SUMMARY: Hits = 27 Lines analyzed = 1452 in approximately 0.07 seconds (21590 lines/second) Physical Source Lines of Code (SLOC) = 1172 Hits@level = [0] 60 [1] 6 [2] 16 [3] 2 [4] 3 [5] 0 Hits@level+ = [0+] 87 [1+] 27 [2+] 21 [3+] 5 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 74.2321 [1+] 23.0375 [2+] 17.9181 [3+] 4.26621 [4+] 2.55973 [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.