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/unyaffs-0.9.7/unyaffs.c Examining data/unyaffs-0.9.7/unyaffs.h FINAL RESULTS: data/unyaffs-0.9.7/unyaffs.c:215:3: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod(name, mode); data/unyaffs-0.9.7/unyaffs.c:523:8: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod(obj->path_name, oh.yst_mode) < 0) data/unyaffs-0.9.7/unyaffs.c:538:8: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod(obj->path_name, oh.yst_mode) < 0) data/unyaffs-0.9.7/unyaffs.c:145:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, format, varg); data/unyaffs-0.9.7/unyaffs.c:203: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(buf, name); data/unyaffs-0.9.7/unyaffs.c:311: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(obj->path_name, oh->name); data/unyaffs-0.9.7/unyaffs.c:313: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(obj->path_name, parent->path_name); data/unyaffs-0.9.7/unyaffs.c:315:4: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(obj->path_name, oh->name); data/unyaffs-0.9.7/unyaffs.c:718:15: [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 ((ch = getopt(argc, argv, "dbc:s:tvVh?")) > 0) { data/unyaffs-0.9.7/unyaffs.c:89:10: [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 data[MAX_CHUNK_SIZE + MAX_SPARE_SIZE]; data/unyaffs-0.9.7/unyaffs.c:90:10: [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 buffer[4*(MAX_CHUNK_SIZE + MAX_SPARE_SIZE)]; data/unyaffs-0.9.7/unyaffs.c:112: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_name[1]; /* variable length, must be last */ data/unyaffs-0.9.7/unyaffs.c:345: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 fsize[16]; data/unyaffs-0.9.7/unyaffs.c:346: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 perm[10]; data/unyaffs-0.9.7/unyaffs.c:423:11: [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 data[MAX_CHUNK_SIZE + MAX_SPARE_SIZE]; data/unyaffs-0.9.7/unyaffs.c:438:3: [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(chunk_data, saved_chunk.data, chunk_size); data/unyaffs-0.9.7/unyaffs.c:439:3: [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(spare_data, saved_chunk.data+chunk_size, spare_size); data/unyaffs-0.9.7/unyaffs.c:476:3: [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(saved_chunk.data, chunk_data, chunk_size); data/unyaffs-0.9.7/unyaffs.c:477:3: [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(saved_chunk.data+chunk_size, spare_data, spare_size); data/unyaffs-0.9.7/unyaffs.c:590:3: [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, buffer+buf_idx, s); data/unyaffs-0.9.7/unyaffs.c:765: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). img_file = open(argv[optind], O_RDONLY); data/unyaffs-0.9.7/unyaffs.h:54: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 name[YAFFS_MAX_NAME_LENGTH + 1]; data/unyaffs-0.9.7/unyaffs.h:76: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 alias[YAFFS_MAX_ALIAS_LENGTH + 1]; data/unyaffs-0.9.7/unyaffs.c:162:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, ptr+offset, len-offset); data/unyaffs-0.9.7/unyaffs.c:201:20: [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 ((buf = malloc(strlen(name)+1)) == NULL) data/unyaffs-0.9.7/unyaffs.c:249:2: [1] (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). Risk is low because the source is a constant character. strcpy(obj->path_name, "."); data/unyaffs-0.9.7/unyaffs.c:299: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). strlen(parent->path_name) + strlen(oh->name) + 2); data/unyaffs-0.9.7/unyaffs.c:299:44: [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). strlen(parent->path_name) + strlen(oh->name) + 2); data/unyaffs-0.9.7/unyaffs.c:314:4: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(obj->path_name, "/"); data/unyaffs-0.9.7/unyaffs.c:350:2: [1] (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). Risk is low because the source is a constant character. strcpy(fsize, "0"); data/unyaffs-0.9.7/unyaffs.c:795:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(0); ANALYSIS SUMMARY: Hits = 31 Lines analyzed = 912 in approximately 0.03 seconds (28166 lines/second) Physical Source Lines of Code (SLOC) = 710 Hits@level = [0] 16 [1] 8 [2] 14 [3] 1 [4] 5 [5] 3 Hits@level+ = [0+] 47 [1+] 31 [2+] 23 [3+] 9 [4+] 8 [5+] 3 Hits/KSLOC@level+ = [0+] 66.1972 [1+] 43.662 [2+] 32.3944 [3+] 12.6761 [4+] 11.2676 [5+] 4.22535 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.