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/libatasmart-0.19/atasmart.h Examining data/libatasmart-0.19/skdump.c Examining data/libatasmart-0.19/atasmart.strpool.c Examining data/libatasmart-0.19/sktest.c Examining data/libatasmart-0.19/strpool.c Examining data/libatasmart-0.19/atasmart.c FINAL RESULTS: data/libatasmart-0.19/atasmart.c:2417:17: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, HIGHLIGHT); data/libatasmart-0.19/atasmart.c:2433:17: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, ENDHIGHLIGHT); data/libatasmart-0.19/atasmart.strpool.c:2596:17: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, HIGHLIGHT); data/libatasmart-0.19/atasmart.strpool.c:2612:17: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, ENDHIGHLIGHT); data/libatasmart-0.19/skdump.c:81:28: [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. if ((opt = getopt_long(argc, argv, "h", long_options, NULL)) < 0) data/libatasmart-0.19/atasmart.c:307:25: [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(data, ioctl_data+4, *len); data/libatasmart-0.19/atasmart.c:1041:9: [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(d, s, len); data/libatasmart-0.19/atasmart.c:2014:17: [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(a.raw, p+5, 6); data/libatasmart-0.19/atasmart.c:2402: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. char name[32]; data/libatasmart-0.19/atasmart.c:2403: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. char pretty[32]; data/libatasmart-0.19/atasmart.c:2404: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. char tt[32], tw[32], tc[32]; data/libatasmart-0.19/atasmart.c:2493:17: [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 pretty[32]; data/libatasmart-0.19/atasmart.c:2777:30: [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 ((d->fd = open(d->name, data/libatasmart-0.19/atasmart.c:2886:17: [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(p, d->identify, sizeof(d->identify)); data/libatasmart-0.19/atasmart.c:2902:17: [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(p, d->smart_data, sizeof(d->smart_data)); data/libatasmart-0.19/atasmart.c:2911:17: [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(p, d->smart_thresholds, sizeof(d->smart_thresholds)); data/libatasmart-0.19/atasmart.c:2952:17: [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(&tag, p, 4); data/libatasmart-0.19/atasmart.c:2953:17: [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(&tsize, p+1, 4); data/libatasmart-0.19/atasmart.c:3018:17: [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(&tag, p, 4); data/libatasmart-0.19/atasmart.c:3019:17: [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(&tsize, p+1, 4); data/libatasmart-0.19/atasmart.c:3035:33: [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(&ok, p, 4); data/libatasmart-0.19/atasmart.h:61: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. char serial[21]; data/libatasmart-0.19/atasmart.h:62: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. char firmware[9]; data/libatasmart-0.19/atasmart.h:63: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. char model[41]; data/libatasmart-0.19/atasmart.strpool.c:472:25: [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(data, ioctl_data+4, *len); data/libatasmart-0.19/atasmart.strpool.c:1206:9: [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(d, s, len); data/libatasmart-0.19/atasmart.strpool.c:2179:17: [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(a.raw, p+5, 6); data/libatasmart-0.19/atasmart.strpool.c:2581: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. char name[32]; data/libatasmart-0.19/atasmart.strpool.c:2582: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. char pretty[32]; data/libatasmart-0.19/atasmart.strpool.c:2583: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. char tt[32], tw[32], tc[32]; data/libatasmart-0.19/atasmart.strpool.c:2672:17: [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 pretty[32]; data/libatasmart-0.19/atasmart.strpool.c:2956:30: [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 ((d->fd = open(d->name, data/libatasmart-0.19/atasmart.strpool.c:3065:17: [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(p, d->identify, sizeof(d->identify)); data/libatasmart-0.19/atasmart.strpool.c:3081:17: [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(p, d->smart_data, sizeof(d->smart_data)); data/libatasmart-0.19/atasmart.strpool.c:3090:17: [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(p, d->smart_thresholds, sizeof(d->smart_thresholds)); data/libatasmart-0.19/atasmart.strpool.c:3131:17: [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(&tag, p, 4); data/libatasmart-0.19/atasmart.strpool.c:3132:17: [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(&tsize, p+1, 4); data/libatasmart-0.19/atasmart.strpool.c:3197:17: [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(&tag, p, 4); data/libatasmart-0.19/atasmart.strpool.c:3198:17: [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(&tsize, p+1, 4); data/libatasmart-0.19/atasmart.strpool.c:3214:33: [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(&ok, p, 4); data/libatasmart-0.19/skdump.c:150:35: [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 (!(f = fopen(device, "r"))) { data/libatasmart-0.19/skdump.c:317:43: [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 (!(f = fopen(file, "w"))) { data/libatasmart-0.19/strpool.c:215:9: [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(r + *rl, *c, n); data/libatasmart-0.19/strpool.c:321:17: [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 t[1024], *c; data/libatasmart-0.19/strpool.c:608:28: [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 (!(in = fopen(argv[1], "r"))) { data/libatasmart-0.19/strpool.c:616:29: [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 (!(out = fopen(argv[2], "w"))) { data/libatasmart-0.19/atasmart.c:221: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). l = strlen(t); data/libatasmart-0.19/atasmart.c:2325:17: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(s, k, len); data/libatasmart-0.19/atasmart.strpool.c:386: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). l = strlen(t); data/libatasmart-0.19/atasmart.strpool.c:2504:17: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(s, k, len); ANALYSIS SUMMARY: Hits = 50 Lines analyzed = 7588 in approximately 0.25 seconds (30903 lines/second) Physical Source Lines of Code (SLOC) = 5645 Hits@level = [0] 146 [1] 4 [2] 41 [3] 1 [4] 4 [5] 0 Hits@level+ = [0+] 196 [1+] 50 [2+] 46 [3+] 5 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 34.721 [1+] 8.8574 [2+] 8.1488 [3+] 0.88574 [4+] 0.708592 [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.