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/genromfs-0.5.2/genromfs.c FINAL RESULTS: data/genromfs-0.5.2/genromfs.c:347:3: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. readlink(node->realname, bigbuf, node->size); data/genromfs-0.5.2/genromfs.c:593:5: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. readlink(n->realname, bigbuf, sizeof(bigbuf)); data/genromfs-0.5.2/genromfs.c:454:2: [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(str, name); data/genromfs-0.5.2/genromfs.c:469:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(str, "%s/%s", base, name); data/genromfs-0.5.2/genromfs.c:471:3: [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(str, name); data/genromfs-0.5.2/genromfs.c:612:6: [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(n->name, devname); data/genromfs-0.5.2/genromfs.c:638:29: [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 (!S_ISLNK(n->modes) && access(n->realname, R_OK)) { data/genromfs-0.5.2/genromfs.c:759:4: [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(pa->pattern, p + 1); data/genromfs-0.5.2/genromfs.c:771:4: [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(pe->pattern, optarg); data/genromfs-0.5.2/genromfs.c:721:14: [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 ((c = getopt(argc, argv, "V:vd:f:ha:A:x:")) != EOF) { data/genromfs-0.5.2/genromfs.c:128: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 pattern[0]; data/genromfs-0.5.2/genromfs.c:133: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 pattern[0]; data/genromfs-0.5.2/genromfs.c:179: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 bigbuf[4096]; data/genromfs-0.5.2/genromfs.c:180: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 fixbuf[512]; data/genromfs-0.5.2/genromfs.c:247: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(fixbuf+atoffs, addr, tocopy); data/genromfs-0.5.2/genromfs.c:292: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(bigbuf, ri, sizeof(*ri)); data/genromfs-0.5.2/genromfs.c:293: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(bigbuf+16, n->name, len); data/genromfs-0.5.2/genromfs.c:356: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(node->realname, O_RDONLY data/genromfs-0.5.2/genromfs.c:605: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 devname[32]; data/genromfs-0.5.2/genromfs.c:711: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[256]; data/genromfs-0.5.2/genromfs.c:786: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(buf, "rom %08lx", time(NULL)); data/genromfs-0.5.2/genromfs.c:797: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). f = fopen(outf, "wb"); data/genromfs-0.5.2/genromfs.c:284: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). dumpdataa(str, strlen(str)+1, f); data/genromfs-0.5.2/genromfs.c:291:8: [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). len = strlen(n->name)+1; data/genromfs-0.5.2/genromfs.c:364:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). len = read(fd, bigbuf, avail); data/genromfs-0.5.2/genromfs.c:448:8: [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). len = strlen(name); data/genromfs-0.5.2/genromfs.c:461:6: [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 (strlen(base)) data/genromfs-0.5.2/genromfs.c:463:15: [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). str = malloc(strlen(base)+len+1); data/genromfs-0.5.2/genromfs.c:468:6: [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 (strlen(base)) { data/genromfs-0.5.2/genromfs.c:512:24: [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). return 16 + ALIGNUP16(strlen(node->name)+1) + ALIGNUP16(node->size); data/genromfs-0.5.2/genromfs.c:756:47: [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). pa = (struct aligns *)malloc(sizeof(*pa) + strlen(p)); data/genromfs-0.5.2/genromfs.c:769:49: [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). pe = (struct excludes *)malloc(sizeof(*pe) + strlen(optarg) + 1); data/genromfs-0.5.2/genromfs.c:804:13: [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). realbase = strlen(dir); ANALYSIS SUMMARY: Hits = 33 Lines analyzed = 813 in approximately 0.04 seconds (18132 lines/second) Physical Source Lines of Code (SLOC) = 644 Hits@level = [0] 31 [1] 11 [2] 12 [3] 1 [4] 7 [5] 2 Hits@level+ = [0+] 64 [1+] 33 [2+] 22 [3+] 10 [4+] 9 [5+] 2 Hits/KSLOC@level+ = [0+] 99.3789 [1+] 51.2422 [2+] 34.1615 [3+] 15.528 [4+] 13.9752 [5+] 3.10559 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.