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/restartd-0.2.3/config.c Examining data/restartd-0.2.3/config.h Examining data/restartd-0.2.3/main.c FINAL RESULTS: data/restartd-0.2.3/main.c:202:21: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(proc_cmdline_name, "/proc/%s/cmdline", data/restartd-0.2.3/main.c:221:29: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(config_process[i].processes, "%s %s", data/restartd-0.2.3/main.c:247:24: [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. system(config_process[i].running); data/restartd-0.2.3/main.c:259:21: [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. system(config_process[i].not_running); data/restartd-0.2.3/config.c:50:22: [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 ((config_fd = fopen(config_file, "rt")) == NULL) { data/restartd-0.2.3/config.h:44: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 name[64]; data/restartd-0.2.3/config.h:45: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 regexp[128]; data/restartd-0.2.3/config.h:46: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 not_running[256]; data/restartd-0.2.3/config.h:47: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 running[256]; data/restartd-0.2.3/config.h:48: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 processes[256]; data/restartd-0.2.3/config.h:49: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 status[32]; data/restartd-0.2.3/main.c:102:17: [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). if (atoi(argv[i + 1]) > 0) { data/restartd-0.2.3/main.c:103:34: [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). check_interval = atoi(argv[i + 1]); data/restartd-0.2.3/main.c:158:13: [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). f = open("/dev/null", O_RDONLY); data/restartd-0.2.3/main.c:170:13: [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). f = open("/dev/null", O_WRONLY); data/restartd-0.2.3/main.c:186:20: [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). out_proc = fopen("/var/run/restartd.pid", "wt"); data/restartd-0.2.3/main.c:201: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). if (atoi(procdir_dirent->d_name) > 0) { data/restartd-0.2.3/main.c:204:36: [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). proc_cmdline = open(proc_cmdline_name, O_RDONLY); data/restartd-0.2.3/main.c:236:23: [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). out_proc = fopen("/var/run/restartd", "wt"); data/restartd-0.2.3/main.c:243:24: [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(config_process[i].status, "running"); data/restartd-0.2.3/main.c:249:25: [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(config_process[i].status, "running"); data/restartd-0.2.3/main.c:255:21: [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(config_process[i].status, "restarting"); data/restartd-0.2.3/main.c:264:21: [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(config_process[i].status, "not running"); data/restartd-0.2.3/config.c:59: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). for(i=0; i<strlen(line1); i++) { data/restartd-0.2.3/config.c:74:31: [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 (line2[0] != 35 && strlen(line2) > 0) { data/restartd-0.2.3/config.c:80:23: [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). while(j < strlen(line2)) { data/restartd-0.2.3/main.c:207:25: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(proc_cmdline, proc_cmdline_str, 1024); data/restartd-0.2.3/main.c:241: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). if (strlen(config_process[i].processes) > 0) { data/restartd-0.2.3/main.c:242: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). if (strlen(config_process[i].running) > 0) { data/restartd-0.2.3/main.c:253:21: [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(config_process[i].processes) == 0 data/restartd-0.2.3/main.c:254: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). && strlen(config_process[i].not_running) > 0) { data/restartd-0.2.3/main.c:262:21: [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(config_process[i].processes) == 0 data/restartd-0.2.3/main.c:263: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). && strlen(config_process[i].not_running) == 0) { ANALYSIS SUMMARY: Hits = 33 Lines analyzed = 480 in approximately 0.04 seconds (13411 lines/second) Physical Source Lines of Code (SLOC) = 341 Hits@level = [0] 31 [1] 10 [2] 19 [3] 0 [4] 4 [5] 0 Hits@level+ = [0+] 64 [1+] 33 [2+] 23 [3+] 4 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 187.683 [1+] 96.7742 [2+] 67.4487 [3+] 11.7302 [4+] 11.7302 [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.