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/cpulimit-2.6/cpulimit.c Examining data/cpulimit-2.6/test/busy.c FINAL RESULTS: data/cpulimit-2.6/cpulimit.c:286:14: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. int size=readlink(exelink,exepath,sizeof(exepath)); data/cpulimit-2.6/cpulimit.c:778:18: [4] (shell) execl: 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. execl(program_data->this_program, program_data->this_program, data/cpulimit-2.6/cpulimit.c:1053:15: [4] (shell) execvp: 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. execvp(argv[last_known_argument], data/cpulimit-2.6/cpulimit.c:1308:33: [4] (shell) execvp: 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. execvp(argv[last_known_argument], data/cpulimit-2.6/cpulimit.c:932:17: [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. next_option = getopt_long (argc, argv, short_options,long_options, NULL); data/cpulimit-2.6/cpulimit.c:118:7: [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. const char *SIGNAL_NAME[MAX_SIGNAL] = { "SIGHUP", "SIGINT", "SIGQUIT", data/cpulimit-2.6/cpulimit.c:194:13: [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 (pid==atoi(dit->d_name)) { data/cpulimit-2.6/cpulimit.c:264: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 exelink[20]; data/cpulimit-2.6/cpulimit.c:265: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 exepath[PATH_MAX+1]; data/cpulimit-2.6/cpulimit.c:283:8: [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). pid=atoi(dit->d_name); data/cpulimit-2.6/cpulimit.c:285:5: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(exelink,"/proc/%d/exe",pid); data/cpulimit-2.6/cpulimit.c:418: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 stat[20]; data/cpulimit-2.6/cpulimit.c:419: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 buffer[1024]; data/cpulimit-2.6/cpulimit.c:421:2: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(stat,"/proc/%d/stat",pid); data/cpulimit-2.6/cpulimit.c:422:10: [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). FILE *f=fopen(stat,"r"); data/cpulimit-2.6/cpulimit.c:434:14: [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). int utime=atoi(p+1); data/cpulimit-2.6/cpulimit.c:437:14: [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). int ktime=atoi(p+1); data/cpulimit-2.6/cpulimit.c:664: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 filename[PROC_FILENAME]; data/cpulimit-2.6/cpulimit.c:667: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 line[256]; data/cpulimit-2.6/cpulimit.c:679: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). status_file = fopen(filename, "r"); data/cpulimit-2.6/cpulimit.c:736:14: [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 filename[PROC_FILENAME]; data/cpulimit-2.6/cpulimit.c:770:18: [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 limit_amount[16]; data/cpulimit-2.6/cpulimit.c:771:18: [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 process_identifier[16]; data/cpulimit-2.6/cpulimit.c:872:23: [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). signal_value = atoi(my_signal); data/cpulimit-2.6/cpulimit.c:944:9: [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). pid=atoi(optarg); data/cpulimit-2.6/cpulimit.c:963: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). perclimit=atoi(optarg); data/cpulimit-2.6/cpulimit.c:968:40: [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). NCPU = atoi(optarg); data/cpulimit-2.6/test/busy.c:16:31: [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 (argc == 2) num_threads = atoi(argv[1]); data/cpulimit-2.6/cpulimit.c:289:71: [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 (process[0]=='/' && strncmp(exepath,process,size)==0 && size==strlen(process)) { data/cpulimit-2.6/cpulimit.c:295:32: [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(exepath+size-strlen(process),process,strlen(process))==0) { data/cpulimit-2.6/cpulimit.c:295:56: [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(exepath+size-strlen(process),process,strlen(process))==0) { data/cpulimit-2.6/test/busy.c:29:2: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). getchar(); ANALYSIS SUMMARY: Hits = 32 Lines analyzed = 1371 in approximately 0.05 seconds (25192 lines/second) Physical Source Lines of Code (SLOC) = 991 Hits@level = [0] 82 [1] 4 [2] 23 [3] 1 [4] 3 [5] 1 Hits@level+ = [0+] 114 [1+] 32 [2+] 28 [3+] 5 [4+] 4 [5+] 1 Hits/KSLOC@level+ = [0+] 115.035 [1+] 32.2906 [2+] 28.2543 [3+] 5.04541 [4+] 4.03633 [5+] 1.00908 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.