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/cputool-0.0.8/cputool.c Examining data/cputool-0.0.8/cputool.h FINAL RESULTS: data/cputool-0.0.8/cputool.c:166:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, format, argptr); data/cputool-0.0.8/cputool.c:210:6: [4] (buffer) fscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. i = fscanf(fd,CPUTOOL_STAT_FORMAT, data/cputool-0.0.8/cputool.c:721:4: [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[0], argv); data/cputool-0.0.8/cputool.c:615:7: [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. c = getopt_long(argc,argv,"p:P:c:l:vVh",long_options,&option_index); data/cputool-0.0.8/cputool.c:178: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 buf[1024]; data/cputool-0.0.8/cputool.c:184:12: [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("/proc/loadavg", O_RDONLY)) > 0) { data/cputool-0.0.8/cputool.c:256:11: [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 statfile[32]; data/cputool-0.0.8/cputool.c:260:4: [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(statfile, "/proc/%d/stat", p->pid); data/cputool-0.0.8/cputool.c:262:18: [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 (!(p->fd = fopen(statfile,"r"))) { data/cputool-0.0.8/cputool.c:323: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(entry->d_name); data/cputool-0.0.8/cputool.c:344:11: [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 statfile[32]; data/cputool-0.0.8/cputool.c:348:4: [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(statfile, "/proc/%d/stat", pid); data/cputool-0.0.8/cputool.c:350: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 (!(fd = fopen(statfile,"r"))) { data/cputool-0.0.8/cputool.c:629:11: [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/cputool-0.0.8/cputool.c:637:11: [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/cputool-0.0.8/cputool.c:641:16: [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). cpuLimit = atoi(optarg); data/cputool-0.0.8/cputool.h:50: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 comm[256]; // %s data/cputool-0.0.8/cputool.c:185:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). len = read(fd, buf, sizeof(buf) - 1); ANALYSIS SUMMARY: Hits = 18 Lines analyzed = 1092 in approximately 0.08 seconds (13781 lines/second) Physical Source Lines of Code (SLOC) = 676 Hits@level = [0] 23 [1] 1 [2] 13 [3] 1 [4] 3 [5] 0 Hits@level+ = [0+] 41 [1+] 18 [2+] 17 [3+] 4 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 60.6509 [1+] 26.6272 [2+] 25.1479 [3+] 5.91716 [4+] 4.43787 [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.