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/msr-tools-1.3/cpuid.c Examining data/msr-tools-1.3/version.h Examining data/msr-tools-1.3/rdmsr.c Examining data/msr-tools-1.3/wrmsr.c FINAL RESULTS: data/msr-tools-1.3/rdmsr.c:358:3: [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. printf(pat, width, data); data/msr-tools-1.3/rdmsr.c:132:3: [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. getopt_long(argc, argv, short_options, long_options, data/msr-tools-1.3/wrmsr.c:90: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(argc, argv, short_options, data/msr-tools-1.3/cpuid.c:41: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 devstr[64]; data/msr-tools-1.3/cpuid.c:45: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(devstr, O_RDONLY); data/msr-tools-1.3/cpuid.c:67: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 string[5] = "xxxx"; data/msr-tools-1.3/rdmsr.c:112: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). rdmsr_on_cpu(reg, atoi(namelist[dir_entries]->d_name)); data/msr-tools-1.3/rdmsr.c:216: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_name[64]; data/msr-tools-1.3/rdmsr.c:219: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_name, "/dev/cpu/%d/msr", cpu); data/msr-tools-1.3/rdmsr.c:220: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_name, O_RDONLY); data/msr-tools-1.3/wrmsr.c:73: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). wrmsr_on_cpu(reg, atoi(namelist[dir_entries]->d_name), data/msr-tools-1.3/wrmsr.c:142: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_name[64]; data/msr-tools-1.3/wrmsr.c:144: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_name, "/dev/cpu/%d/msr", cpu); data/msr-tools-1.3/wrmsr.c:145: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_name, O_WRONLY); ANALYSIS SUMMARY: Hits = 14 Lines analyzed = 744 in approximately 0.03 seconds (21715 lines/second) Physical Source Lines of Code (SLOC) = 593 Hits@level = [0] 26 [1] 0 [2] 11 [3] 2 [4] 1 [5] 0 Hits@level+ = [0+] 40 [1+] 14 [2+] 14 [3+] 3 [4+] 1 [5+] 0 Hits/KSLOC@level+ = [0+] 67.4536 [1+] 23.6088 [2+] 23.6088 [3+] 5.05902 [4+] 1.68634 [5+] 0 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.