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/moreutils-0.64/errno.c Examining data/moreutils-0.64/ifdata.c Examining data/moreutils-0.64/ifne.c Examining data/moreutils-0.64/is_utf8/is_utf8.c Examining data/moreutils-0.64/is_utf8/is_utf8.h Examining data/moreutils-0.64/is_utf8/main.c Examining data/moreutils-0.64/lckdo.c Examining data/moreutils-0.64/mispipe.c Examining data/moreutils-0.64/parallel.c Examining data/moreutils-0.64/pee.c Examining data/moreutils-0.64/physmem.c Examining data/moreutils-0.64/sponge.c FINAL RESULTS: data/moreutils-0.64/sponge.c:362:7: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chmod(tmpname, mode) != 0) { data/moreutils-0.64/errno.c:113:9: [4] (shell) popen: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. f = popen("locale -a", "r"); data/moreutils-0.64/ifne.c:97:3: [4] (shell) execvp: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execvp(*argv_exec, argv_exec); data/moreutils-0.64/lckdo.c:35:23: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__((format(printf,3,4))) data/moreutils-0.64/lckdo.c:40:21: [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. va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); data/moreutils-0.64/lckdo.c:230:2: [4] (shell) execvp: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execvp(*argv, argv); data/moreutils-0.64/mispipe.c:63:35: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__(( noreturn, format (printf, 1, 2) )) data/moreutils-0.64/mispipe.c:68: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, formatstr, ap); data/moreutils-0.64/mispipe.c:117:6: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. if (system(cmd)) {} data/moreutils-0.64/mispipe.c:161:15: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. status_big = system(argv[1]); data/moreutils-0.64/parallel.c:95:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "%s%s%s", command[i], arguments[0], s+2); data/moreutils-0.64/parallel.c:102:3: [4] (shell) execvp: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execvp(argv[0], argv); data/moreutils-0.64/parallel.c:106:11: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. int ret=system(arguments[0]); data/moreutils-0.64/parallel.c:339:51: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. #warning Cannot autodetect number of CPUS on this system: _SC_NPROCESSORS_ONLN not defined. data/moreutils-0.64/pee.c:74:18: [4] (shell) popen: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. pipes[i - 1] = popen(argv[i], "w"); data/moreutils-0.64/sponge.c:260:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(tmpname, template, tmpdir); data/moreutils-0.64/errno.c:164:17: [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. int c = getopt_long(argc, argv, "hlsS", options, &index); data/moreutils-0.64/is_utf8/main.c:238:19: [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(ac, av, "hqliv", options, NULL)) != -1) { data/moreutils-0.64/lckdo.c:100: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, "+wW:neE:sxtq")) != EOF) { data/moreutils-0.64/parallel.c:289:16: [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. (opt = getopt(argc, argv, "+hij:l:n:")) != -1) { data/moreutils-0.64/sponge.c:251:11: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. tmpdir = getenv("TMPDIR"); data/moreutils-0.64/sponge.c:290:16: [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 ((opt = getopt(argc, argv, "ha")) != -1) { data/moreutils-0.64/errno.c:111: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 line[1024]; data/moreutils-0.64/errno.c:204:39: [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). if (!report_from_code(atoi(arg))) data/moreutils-0.64/ifdata.c:266: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[10]; data/moreutils-0.64/ifdata.c:273:12: [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 ((fd = fopen("/proc/net/dev", "r")) == NULL) { data/moreutils-0.64/ifne.c:51: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[BUFSIZ]; data/moreutils-0.64/is_utf8/main.c:178: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(file_path, O_RDONLY); data/moreutils-0.64/is_utf8/main.c:188:33: [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). return is_utf8_readline(fopen(file_path, "r"), file_path, data/moreutils-0.64/lckdo.c:107:20: [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). if ((waittime = atoi(optarg)) < 1) data/moreutils-0.64/lckdo.c:117:15: [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). if ((fdn = atoi(optarg)) < 0 || fdn == 2) data/moreutils-0.64/lckdo.c:149: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(lckfile, create, 0666); data/moreutils-0.64/parallel.c:101:4: [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(argv + i - 1, arguments, nargs * sizeof(char *)); data/moreutils-0.64/parallel.c:189: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[4096]; data/moreutils-0.64/parallel.c:247: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[128]; data/moreutils-0.64/parallel.c:249: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("/proc/loadavg", O_RDONLY); data/moreutils-0.64/pee.c:40: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[BUFSIZ]; data/moreutils-0.64/sponge.c:224:33: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). static void copy_tmpfile (FILE *tmpfile, FILE *outfile, char *buf, size_t size) { data/moreutils-0.64/sponge.c:225:19: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). if (lseek(fileno(tmpfile), 0, SEEK_SET)) { data/moreutils-0.64/sponge.c:227:10: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). fclose(tmpfile); data/moreutils-0.64/sponge.c:230:12: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). copy_file(tmpfile, outfile, buf, size); data/moreutils-0.64/sponge.c:231:13: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). if (fclose(tmpfile) != 0) { data/moreutils-0.64/sponge.c:244:8: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). FILE *tmpfile; data/moreutils-0.64/sponge.c:262:10: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). tmpfd = mkstemp(tmpname); data/moreutils-0.64/sponge.c:272:8: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). if (! tmpfile) { data/moreutils-0.64/sponge.c:276:9: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). return tmpfile; data/moreutils-0.64/sponge.c:312:39: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). write_buff_tmp(bufstart, bufused, tmpfile); data/moreutils-0.64/sponge.c:344:14: [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). outfile = fopen(outname, "r"); data/moreutils-0.64/sponge.c:345:23: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). copy_file(outfile, tmpfile, tmpbuf, bufsize); data/moreutils-0.64/sponge.c:349:44: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). write_buff_tmp_finish(bufstart, bufused, tmpfile); data/moreutils-0.64/sponge.c:375:14: [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). outfile = fopen(outname, "w"); data/moreutils-0.64/sponge.c:380:17: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). copy_tmpfile(tmpfile, outfile, bufstart, bufsize); data/moreutils-0.64/sponge.c:385:45: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). write_buff_tmp_finish(bufstart, bufused, tmpfile); data/moreutils-0.64/sponge.c:386:17: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). copy_tmpfile(tmpfile, stdout, bufstart, bufsize); data/moreutils-0.64/ifdata.c:124:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(req->ifr_name, ifname, IFNAMSIZ); data/moreutils-0.64/ifdata.c:259:8: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch = getc(fd); data/moreutils-0.64/ifne.c:36:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). r = read(0, buf, BUFSIZ*sizeof(char)); data/moreutils-0.64/ifne.c:67:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). r = read(0, buf, BUFSIZ*sizeof(char)); data/moreutils-0.64/parallel.c:93:22: [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). char *buf=malloc(strlen(command[i]) + strlen(arguments[0])); data/moreutils-0.64/parallel.c:93:43: [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). char *buf=malloc(strlen(command[i]) + strlen(arguments[0])); data/moreutils-0.64/parallel.c:192:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((r = read(fd, buf, sizeof(buf))) >= 0) { data/moreutils-0.64/parallel.c:253:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). n = read(fd, buf, sizeof(buf)-1); data/moreutils-0.64/parallel.c:300:36: [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 (errno != 0 || (t-optarg) != strlen(optarg)) { data/moreutils-0.64/parallel.c:309:36: [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 (errno != 0 || (t-optarg) != strlen(optarg)) { data/moreutils-0.64/parallel.c:318:54: [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 (errno != 0 || argsatonce < 1 || (t-optarg) != strlen(optarg)) { data/moreutils-0.64/pee.c:87:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). r = read(STDIN_FILENO, buf, BUFSIZ); data/moreutils-0.64/sponge.c:214:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((i = read(fileno(infile), buf, size)) > 0) { data/moreutils-0.64/sponge.c:255: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). tmpname=malloc(strlen(tmpdir) + strlen(template) - 2 + 1); data/moreutils-0.64/sponge.c:255:34: [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). tmpname=malloc(strlen(tmpdir) + strlen(template) - 2 + 1); data/moreutils-0.64/sponge.c:261:7: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). mask=umask(077); data/moreutils-0.64/sponge.c:263:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(mask); data/moreutils-0.64/sponge.c:308:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((i = read(0, buf, bufsize - bufused)) > 0) { data/moreutils-0.64/sponge.c:358:18: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). mode_t mask = umask(0); data/moreutils-0.64/sponge.c:359:4: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(mask); ANALYSIS SUMMARY: Hits = 74 Lines analyzed = 3198 in approximately 0.12 seconds (26967 lines/second) Physical Source Lines of Code (SLOC) = 2499 Hits@level = [0] 90 [1] 20 [2] 32 [3] 6 [4] 15 [5] 1 Hits@level+ = [0+] 164 [1+] 74 [2+] 54 [3+] 22 [4+] 16 [5+] 1 Hits/KSLOC@level+ = [0+] 65.6263 [1+] 29.6118 [2+] 21.6086 [3+] 8.80352 [4+] 6.40256 [5+] 0.40016 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.