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/scrub-2.6.1/test/pat.c Examining data/scrub-2.6.1/test/tsig.c Examining data/scrub-2.6.1/test/tgetsize.c Examining data/scrub-2.6.1/test/tsize.c Examining data/scrub-2.6.1/test/tprogress.c Examining data/scrub-2.6.1/test/trand.c Examining data/scrub-2.6.1/test/pad.c Examining data/scrub-2.6.1/test/aestest.c Examining data/scrub-2.6.1/src/hwrand.h Examining data/scrub-2.6.1/src/hwrand.c Examining data/scrub-2.6.1/src/sig.c Examining data/scrub-2.6.1/src/pattern.h Examining data/scrub-2.6.1/src/genrand.h Examining data/scrub-2.6.1/src/util.h Examining data/scrub-2.6.1/src/fillfile.c Examining data/scrub-2.6.1/src/scrub.c Examining data/scrub-2.6.1/src/aes.h Examining data/scrub-2.6.1/src/sig.h Examining data/scrub-2.6.1/src/getsize.h Examining data/scrub-2.6.1/src/util.c Examining data/scrub-2.6.1/src/fillfile.h Examining data/scrub-2.6.1/src/filldentry.h Examining data/scrub-2.6.1/src/pattern.c Examining data/scrub-2.6.1/src/progress.c Examining data/scrub-2.6.1/src/filldentry.c Examining data/scrub-2.6.1/src/progress.h Examining data/scrub-2.6.1/src/aes.c Examining data/scrub-2.6.1/src/genrand.c Examining data/scrub-2.6.1/src/getsize.c Examining data/scrub-2.6.1/libscrub/scrub.h Examining data/scrub-2.6.1/libscrub/libscrub.c Examining data/scrub-2.6.1/libscrub/tscrub.c FINAL RESULTS: data/scrub-2.6.1/libscrub/libscrub.c:252:17: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(path, R_OK|W_OK) < 0) { data/scrub-2.6.1/libscrub/libscrub.c:263:17: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(path, R_OK|W_OK) < 0) { data/scrub-2.6.1/src/filldentry.c:119:5: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(path, new); data/scrub-2.6.1/src/scrub.c:318:24: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. } else if (access(filename, R_OK|W_OK) < 0) { data/scrub-2.6.1/src/scrub.c:356:17: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(filename, R_OK|W_OK) < 0) { data/scrub-2.6.1/libscrub/tscrub.c:85:17: [3] (buffer) getopt: 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 ((f = getopt (argc, argv, "X:p:")) != -1) { data/scrub-2.6.1/src/scrub.c:87:32: [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. #define GETOPT(ac,av,opt,lopt) getopt_long(ac,av,opt,lopt,NULL) data/scrub-2.6.1/src/scrub.c:107:32: [3] (buffer) getopt: 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. #define GETOPT(ac,av,opt,lopt) getopt(ac,av,opt) data/scrub-2.6.1/test/pat.c:47:32: [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. #define GETOPT(ac,av,opt,lopt) getopt_long(ac,av,opt,lopt,NULL) data/scrub-2.6.1/test/pat.c:55:32: [3] (buffer) getopt: 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. #define GETOPT(ac,av,opt,lopt) getopt(ac,av,opt) data/scrub-2.6.1/libscrub/libscrub.c:293: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 path[MAXPATHLEN]; data/scrub-2.6.1/libscrub/libscrub.c:369: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 buf[80]; data/scrub-2.6.1/src/filldentry.c:57:15: [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(dir, O_RDONLY)) < 0) data/scrub-2.6.1/src/fillfile.c:93:5: [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(mem, mp->buf, memsize); data/scrub-2.6.1/src/fillfile.c:173:10: [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(path, openflags, 0644); data/scrub-2.6.1/src/fillfile.c:177:14: [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(path, openflags, 0644); data/scrub-2.6.1/src/fillfile.c:247:10: [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(path, openflags); data/scrub-2.6.1/src/fillfile.c:251:14: [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(path, openflags); data/scrub-2.6.1/src/genrand.c:56: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. static unsigned char ctr[PAYLOAD_SZ]; data/scrub-2.6.1/src/genrand.c:61: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 rstate[128]; data/scrub-2.6.1/src/genrand.c:92:14: [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(PATH_URANDOM, O_RDONLY); data/scrub-2.6.1/src/genrand.c:129: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. unsigned char key[KEY_SZ]; data/scrub-2.6.1/src/genrand.c:177: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. unsigned char out[PAYLOAD_SZ]; data/scrub-2.6.1/src/genrand.c:191: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(&buf[i], out, cpylen); data/scrub-2.6.1/src/getsize.c:60:15: [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(path, O_RDONLY)) < 0) data/scrub-2.6.1/src/getsize.c:100:15: [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(path, O_RDONLY)) < 0) data/scrub-2.6.1/src/getsize.c:126:15: [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(path, O_RDONLY)) < 0) data/scrub-2.6.1/src/getsize.c:153:15: [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(path, O_RDONLY)) < 0) data/scrub-2.6.1/src/getsize.c:181:15: [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(path, O_RDONLY)) < 0) data/scrub-2.6.1/src/getsize.c:221:15: [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(path, O_RDONLY)) < 0) data/scrub-2.6.1/src/pattern.c:290: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 tmp[16]; data/scrub-2.6.1/src/pattern.c:301:13: [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 (tmp, s + 2, 2); data/scrub-2.6.1/src/pattern.c:309:13: [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 (tmp, s + 1, 3); data/scrub-2.6.1/src/pattern.c:395:12: [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 str[MAXPATBYTES*2 + 3]; data/scrub-2.6.1/src/pattern.c:426: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 buf[80]; data/scrub-2.6.1/src/scrub.c:435: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 sizestr[80]; data/scrub-2.6.1/src/scrub.c:573: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 path[MAXPATHLEN]; data/scrub-2.6.1/src/scrub.c:686: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 rpath[MAXPATHLEN]; data/scrub-2.6.1/src/sig.c:75:15: [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(path, O_RDWR)) < 0) data/scrub-2.6.1/src/sig.c:79:5: [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(buf, SCRUB_MAGIC, sizeof(SCRUB_MAGIC)); data/scrub-2.6.1/src/sig.c:114:15: [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(path, O_RDONLY)) < 0) data/scrub-2.6.1/test/aestest.c:37: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. static unsigned char AES_enc_test[3][16] = data/scrub-2.6.1/test/aestest.c:47: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. static unsigned char AES_dec_test[3][16] = data/scrub-2.6.1/test/aestest.c:61: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. unsigned char buf[16]; data/scrub-2.6.1/test/aestest.c:62: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. unsigned char key[32]; data/scrub-2.6.1/test/pad.c:100:10: [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(filename, O_CREAT | O_RDWR, 0644); data/scrub-2.6.1/test/tgetsize.c:48: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 buf[80]; data/scrub-2.6.1/test/trand.c:40: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. unsigned char buf[24]; data/scrub-2.6.1/src/filldentry.c:81:12: [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). assert(strlen(old) > 0); data/scrub-2.6.1/src/filldentry.c:91:27: [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). memset(base, pat, strlen(base)); data/scrub-2.6.1/src/filldentry.c:111:12: [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). assert(strlen(cpy) == strlen(new)); data/scrub-2.6.1/src/filldentry.c:111:27: [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). assert(strlen(cpy) == strlen(new)); data/scrub-2.6.1/src/filldentry.c:118:12: [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). assert(strlen(path) == strlen(new)); data/scrub-2.6.1/src/filldentry.c:118:28: [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). assert(strlen(path) == strlen(new)); data/scrub-2.6.1/src/pattern.c:299:27: [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 (*s == '\\' && strlen (s) >= 4 && *(s + 1) == 'x' data/scrub-2.6.1/src/pattern.c:307:27: [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 (*s == '\\' && strlen (s) >= 4 && isoctdigit (*(s + 1)) data/scrub-2.6.1/src/scrub.c:167:52: [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 (optarg, "custom=", 7) && strlen (optarg) > 7) { data/scrub-2.6.1/src/sig.c:56:27: [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). *blocksize = blkalign(strlen(SCRUB_MAGIC), sb.st_blksize, UP); data/scrub-2.6.1/src/sig.c:118:14: [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 (n >= strlen(SCRUB_MAGIC)) { data/scrub-2.6.1/src/sig.c:119:38: [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 (memcmp(buf, SCRUB_MAGIC, strlen(SCRUB_MAGIC)) == 0) data/scrub-2.6.1/src/util.c:46:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). n = read(fd, buf, count); data/scrub-2.6.1/src/util.c:136:11: [1] (free) memalign: On some systems (though not Linux-based systems) an attempt to free() results from memalign() may fail. This may, on a few systems, be exploitable. Also note that memalign() may not check that the boundary parameter is correct (CWE-676). Use posix_memalign instead (defined in POSIX's 1003.1d). Don't switch to valloc(); it is marked as obsolete in BSD 4.3, as legacy in SUSv2, and is no longer defined in SUSv3. In some cases, malloc()'s alignment may be sufficient. ptr = memalign(ALIGNMENT, bufsize); data/scrub-2.6.1/test/pat.c:94:16: [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 (size < strlen(SCRUB_MAGIC) + 1) { data/scrub-2.6.1/test/pat.c:100:17: [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). size -= strlen(SCRUB_MAGIC); ANALYSIS SUMMARY: Hits = 64 Lines analyzed = 5005 in approximately 0.17 seconds (30076 lines/second) Physical Source Lines of Code (SLOC) = 3747 Hits@level = [0] 142 [1] 16 [2] 38 [3] 5 [4] 5 [5] 0 Hits@level+ = [0+] 206 [1+] 64 [2+] 48 [3+] 10 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 54.9773 [1+] 17.0803 [2+] 12.8102 [3+] 2.6688 [4+] 1.3344 [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.