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/psst-1.0/src/perf_msr.h Examining data/psst-1.0/src/parse_config.c Examining data/psst-1.0/src/parse_config.h Examining data/psst-1.0/src/psst.h Examining data/psst-1.0/src/perf_msr.c Examining data/psst-1.0/src/rapl.c Examining data/psst-1.0/src/rapl.h Examining data/psst-1.0/src/logger.c Examining data/psst-1.0/src/logger.h Examining data/psst-1.0/src/psst.c FINAL RESULTS: data/psst-1.0/src/logger.c:85:7: [4] (shell) popen: 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. fp = popen(path, "r"); data/psst-1.0/src/logger.c:112:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cmd, "find %s* -name %s 2>/dev/null | wc -l", base, match); data/psst-1.0/src/logger.c:113:7: [4] (shell) popen: 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. fp = popen(cmd, "r"); data/psst-1.0/src/logger.c:137:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(path, "cat %s/%s 2>/dev/null", base, node); data/psst-1.0/src/logger.c:138:7: [4] (shell) popen: 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. fp = popen(path, "r"); data/psst-1.0/src/logger.c:166:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(path, "find %s* -name %s 2>/dev/null", base, node); data/psst-1.0/src/logger.c:167:7: [4] (shell) popen: 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. fp = popen(path, "r"); data/psst-1.0/src/logger.c:693:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(hdr_fmt, "%%%ds%s", data/psst-1.0/src/logger.c:695:10: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sz1 = sprintf(log_header + sz, hdr_fmt, data/psst-1.0/src/logger.c:708:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(hdr_fmt, "%%%ds%s", data/psst-1.0/src/logger.c:710:10: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sz1 = sprintf(log_header + sz, hdr_fmt, data/psst-1.0/src/logger.c:739:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(val_fmt, "%%%sf%s", col_desc[i].fmt, delim); data/psst-1.0/src/logger.c:740:9: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sz1 = sprintf(final_buf + sz, val_fmt, data/psst-1.0/src/logger.h:22:28: [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. #define dbg_print(fmt...) printf(fmt) data/psst-1.0/src/parse_config.c:283:4: [4] (buffer) sscanf: 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. sscanf(optarg, "%s", buf); data/psst-1.0/src/parse_config.c:267:14: [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 ((c = getopt_long(ac, av, "s:G:C:E:l:p:d:hvVT", data/psst-1.0/src/logger.c:108: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 cmd[MAX_LEN]; data/psst-1.0/src/logger.c:109: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 result[8]; data/psst-1.0/src/logger.c:128: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). return atoi(result); data/psst-1.0/src/logger.c:135: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 path[MAX_LEN]; data/psst-1.0/src/logger.c:162: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 value[64], path[MAX_LEN]; data/psst-1.0/src/logger.c:163: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 list[2048] = {0}; data/psst-1.0/src/logger.c:186:8: [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). fd = open(token, O_RDONLY); data/psst-1.0/src/logger.c:219: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 *page[2]; data/psst-1.0/src/logger.c:256:2: [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(active_pg + active_pg_filled, record, sz); data/psst-1.0/src/logger.c:335: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 path[MAX_LEN] = ""; data/psst-1.0/src/logger.c:415:25: [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). col_desc[i].poll_fd = open(path, 0, "r"); data/psst-1.0/src/logger.c:529: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[64]; data/psst-1.0/src/logger.c:530: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 final_buf[512]; data/psst-1.0/src/logger.c:531: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 val_fmt[16]; data/psst-1.0/src/logger.c:669:24: [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). col_desc[i].value = atoi(buf); data/psst-1.0/src/logger.c:685: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 hdr_fmt[16]; data/psst-1.0/src/logger.c:688:3: [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(log_header, "%c", '#'); data/psst-1.0/src/logger.c:694:6: [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). atoi(col_desc[i].fmt), delim); data/psst-1.0/src/logger.c:703:3: [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(log_header+sz, "%c", '#'); data/psst-1.0/src/logger.c:709:6: [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). atoi(col_desc[i].fmt), delim); data/psst-1.0/src/logger.c:716:3: [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(log_header+sz, "%c", '#'); data/psst-1.0/src/logger.c:719:10: [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. sz1 = sprintf(log_header + sz, "%c", '-'); data/psst-1.0/src/logger.h:57: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 header_name[32]; data/psst-1.0/src/logger.h:58: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 unit[32]; data/psst-1.0/src/logger.h:59: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 fmt[32]; data/psst-1.0/src/parse_config.c:129:26: [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). configp->log_file_fd = open(configp->log_file_name, data/psst-1.0/src/parse_config.c:178: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). k = atoi(token); data/psst-1.0/src/parse_config.c:183: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). k = atoi(subtoken); data/psst-1.0/src/parse_config.c:186:18: [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). while (++k <= atoi(pos)) data/psst-1.0/src/parse_config.c:197: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[65]; data/psst-1.0/src/parse_config.c:202:7: [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). fp = fopen("/sys/devices/system/cpu/online", "r"); data/psst-1.0/src/parse_config.c:258: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[128]; data/psst-1.0/src/parse_config.h:55: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 log_file_name[80]; data/psst-1.0/src/parse_config.h:57: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 shape_func[20]; data/psst-1.0/src/perf_msr.c:41: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 msr_file[128]; data/psst-1.0/src/perf_msr.c:43: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(msr_file, "/dev/cpu/%d/msr", c); data/psst-1.0/src/perf_msr.c:44:7: [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). fd = open(msr_file, O_RDONLY); data/psst-1.0/src/logger.c:125:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(result, cmd, sz); data/psst-1.0/src/logger.c:151:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(result, path, sz); data/psst-1.0/src/logger.c:188:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). sz = read(fd, value, sizeof(value)); data/psst-1.0/src/logger.c:209:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buf, token, sz); data/psst-1.0/src/logger.c:211:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buf+sz, replace, replace_sz); data/psst-1.0/src/logger.c:573:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). sz = read(col_desc[i].poll_fd, buf, 64); data/psst-1.0/src/parse_config.c:84:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(configp->shape_func, "single-step,0.1", 16); data/psst-1.0/src/parse_config.c:120:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(configp->log_file_name, default_log_file, data/psst-1.0/src/parse_config.c:185:18: [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). pos = token + strlen(subtoken) + 1; data/psst-1.0/src/parse_config.c:223:18: [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). int arg_bytes = strlen(buf); data/psst-1.0/src/parse_config.c:273:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(configp->log_file_name, optarg, len); data/psst-1.0/src/parse_config.c:301:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(configp->shape_func, optarg, len); ANALYSIS SUMMARY: Hits = 65 Lines analyzed = 2204 in approximately 0.07 seconds (32362 lines/second) Physical Source Lines of Code (SLOC) = 1704 Hits@level = [0] 75 [1] 12 [2] 37 [3] 1 [4] 15 [5] 0 Hits@level+ = [0+] 140 [1+] 65 [2+] 53 [3+] 16 [4+] 15 [5+] 0 Hits/KSLOC@level+ = [0+] 82.1596 [1+] 38.1455 [2+] 31.1033 [3+] 9.38967 [4+] 8.80282 [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.