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/erofs-utils-1.1/include/erofs/cache.h
Examining data/erofs-utils-1.1/include/erofs/compress.h
Examining data/erofs-utils-1.1/include/erofs/config.h
Examining data/erofs-utils-1.1/include/erofs/defs.h
Examining data/erofs-utils-1.1/include/erofs/err.h
Examining data/erofs-utils-1.1/include/erofs/exclude.h
Examining data/erofs-utils-1.1/include/erofs/hashtable.h
Examining data/erofs-utils-1.1/include/erofs/inode.h
Examining data/erofs-utils-1.1/include/erofs/internal.h
Examining data/erofs-utils-1.1/include/erofs/io.h
Examining data/erofs-utils-1.1/include/erofs/list.h
Examining data/erofs-utils-1.1/include/erofs/print.h
Examining data/erofs-utils-1.1/include/erofs/xattr.h
Examining data/erofs-utils-1.1/include/erofs_fs.h
Examining data/erofs-utils-1.1/lib/cache.c
Examining data/erofs-utils-1.1/lib/compress.c
Examining data/erofs-utils-1.1/lib/compressor.c
Examining data/erofs-utils-1.1/lib/compressor.h
Examining data/erofs-utils-1.1/lib/compressor_lz4.c
Examining data/erofs-utils-1.1/lib/compressor_lz4hc.c
Examining data/erofs-utils-1.1/lib/config.c
Examining data/erofs-utils-1.1/lib/exclude.c
Examining data/erofs-utils-1.1/lib/inode.c
Examining data/erofs-utils-1.1/lib/io.c
Examining data/erofs-utils-1.1/lib/xattr.c
Examining data/erofs-utils-1.1/mkfs/main.c

FINAL RESULTS:

data/erofs-utils-1.1/lib/inode.c:841:10:  [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.
			ret = readlink(dir->i_srcpath, symlink, dir->i_size);
data/erofs-utils-1.1/include/erofs/internal.h:165:2:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
	sprintf(msg, "[Error %d] %s", -err, strerror(-err));
data/erofs-utils-1.1/include/erofs/print.h:32:3:  [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(stdout,					\
data/erofs-utils-1.1/include/erofs/print.h:42:3:  [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(stdout,					\
data/erofs-utils-1.1/include/erofs/print.h:53:3:  [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(stdout,					\
data/erofs-utils-1.1/include/erofs/print.h:64:3:  [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,					\
data/erofs-utils-1.1/include/erofs/print.h:72:30:  [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.
#define erofs_dump(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
data/erofs-utils-1.1/lib/exclude.c:119:3:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
		sprintf(buf, "%s/%s", dir, name);
data/erofs-utils-1.1/mkfs/main.c:135:15:  [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((opt = getopt_long(argc, argv, "d:x:z:E:T:",
data/erofs-utils-1.1/mkfs/main.c:222:19:  [3] (buffer) realpath:
  This function does not protect against buffer overflows, and some
  implementations can overflow internally (CWE-120/CWE-785!). Ensure that the
  destination buffer is at least of size MAXPATHLEN, andto protect against
  implementation problems, the input argument should also be checked to
  ensure it is no larger than MAXPATHLEN.
	cfg.c_src_path = realpath(argv[optind++], NULL);
data/erofs-utils-1.1/include/erofs/internal.h:114: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 i_srcpath[PATH_MAX + 1];
data/erofs-utils-1.1/include/erofs/internal.h:143: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[EROFS_NAME_LEN];
data/erofs-utils-1.1/include/erofs/internal.h:163: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 msg[256];
data/erofs-utils-1.1/include/erofs_fs.h:174: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   e_name[0];       /* attribute name */
data/erofs-utils-1.1/lib/compress.c:60: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(ctx->metacur, &di, sizeof(di));
data/erofs-utils-1.1/lib/compress.c:83: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(ctx->metacur, &di, sizeof(di));
data/erofs-utils-1.1/lib/compress.c:105: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(ctx->metacur, &di, sizeof(di));
data/erofs-utils-1.1/lib/compress.c:136: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(dst, ctx->queue + ctx->head, count);
data/erofs-utils-1.1/lib/compress.c:155: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 dstbuf[EROFS_BLKSIZ * 2];
data/erofs-utils-1.1/lib/compress.c:349: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(out, &mapheader, sizeof(mapheader));
data/erofs-utils-1.1/lib/compress.c:404: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(inode->i_srcpath, O_RDONLY | O_BINARY);
data/erofs-utils-1.1/lib/exclude.c:29: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 str[512];
data/erofs-utils-1.1/lib/exclude.c:111: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[PATH_MAX];
data/erofs-utils-1.1/lib/inode.c:28: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 erofs_type_by_mode[S_IFMT >> S_SHIFT] = {
data/erofs-utils-1.1/lib/inode.c:210: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(buf + p, &d, sizeof(d));
data/erofs-utils-1.1/lib/inode.c:211: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(buf + q, head->name, namelen);
data/erofs-utils-1.1/lib/inode.c:223: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[EROFS_BLKSIZ];
data/erofs-utils-1.1/lib/inode.c:294: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(inode->idata, buf + blknr_to_addr(nblocks),
data/erofs-utils-1.1/lib/inode.c:319: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 buf[EROFS_BLKSIZ];
data/erofs-utils-1.1/lib/inode.c:367: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(inode->i_srcpath, O_RDONLY | O_BINARY);
data/erofs-utils-1.1/lib/inode.c:910: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 buf[PATH_MAX];
data/erofs-utils-1.1/lib/io.c:65: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(dev, O_RDWR | O_CREAT | O_BINARY, 0644);
data/erofs-utils-1.1/lib/io.c:152:15:  [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 const char zero[EROFS_BLKSIZ] = {0};
data/erofs-utils-1.1/lib/xattr.c:76:48:  [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 int xattr_item_hash(u8 prefix, char *buf,
data/erofs-utils-1.1/lib/xattr.c:93:52:  [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 struct xattr_item *get_xattritem(u8 prefix, char *kvbuf,
data/erofs-utils-1.1/lib/xattr.c:172: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(kvbuf, key + prefixlen, len[0]);
data/erofs-utils-1.1/lib/xattr.c:325: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 buf[PATH_MAX];
data/erofs-utils-1.1/lib/xattr.c:450: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(buf + p, &entry, sizeof(entry));
data/erofs-utils-1.1/lib/xattr.c:452: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(buf + p, item->kvbuf, item->len[0] + item->len[1]);
data/erofs-utils-1.1/lib/xattr.c:504: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(buf + p, &entry, sizeof(entry));
data/erofs-utils-1.1/lib/xattr.c:506: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(buf + p, item->kvbuf, item->len[0] + item->len[1]);
data/erofs-utils-1.1/mkfs/main.c:147:7:  [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).
						atoi(optarg + i + 1);
data/erofs-utils-1.1/mkfs/main.c:156:8:  [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).
			i = atoi(optarg);
data/erofs-utils-1.1/mkfs/main.c:268: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(buf + EROFS_SUPER_OFFSET, &sb, sizeof(sb));
data/erofs-utils-1.1/mkfs/main.c:334: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 uuid_str[37] = "not available";
data/erofs-utils-1.1/lib/compress.c:430:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		ret = read(fd, ctx.queue + ctx.tail, readcount);
data/erofs-utils-1.1/lib/exclude.c:24: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).
	rpathlen = strlen(rootdir);
data/erofs-utils-1.1/lib/inode.c:119:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(d->name, name, EROFS_NAME_LEN - 1);
data/erofs-utils-1.1/lib/inode.c:175: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).
		int len = strlen(d->name) + sizeof(struct erofs_dirent);
data/erofs-utils-1.1/lib/inode.c:203:32:  [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).
		const unsigned int namelen = strlen(head->name);
data/erofs-utils-1.1/lib/inode.c:241: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).
		const unsigned int len = strlen(d->name) +
data/erofs-utils-1.1/lib/inode.c:321:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		ret = read(fd, buf, EROFS_BLKSIZ);
data/erofs-utils-1.1/lib/inode.c:340:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		ret = read(fd, inode->idata, inode->idata_size);
data/erofs-utils-1.1/lib/inode.c:704:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(inode->i_srcpath, path, sizeof(inode->i_srcpath) - 1);
data/erofs-utils-1.1/lib/inode.c:878:42:  [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).
		    !strncmp(dp->d_name, "lost+found", strlen("lost+found")))
data/erofs-utils-1.1/lib/xattr.c:251:25:  [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).
		unsigned int keylen = strlen(key);
data/erofs-utils-1.1/lib/xattr.c:337:42:  [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).
		    !strncmp(dp->d_name, "lost+found", strlen("lost+found")))
data/erofs-utils-1.1/mkfs/main.c:84: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).
			p = token + strlen(token);

ANALYSIS SUMMARY:

Hits = 58
Lines analyzed = 5173 in approximately 0.18 seconds (29554 lines/second)
Physical Source Lines of Code (SLOC) = 3732
Hits@level = [0]   3 [1]  13 [2]  35 [3]   2 [4]   7 [5]   1
Hits@level+ = [0+]  61 [1+]  58 [2+]  45 [3+]  10 [4+]   8 [5+]   1
Hits/KSLOC@level+ = [0+] 16.3451 [1+] 15.5413 [2+] 12.0579 [3+] 2.67953 [4+] 2.14362 [5+] 0.267953
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.