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/mingetty-1.08/mingetty.c FINAL RESULTS: data/mingetty-1.08/mingetty.c:147:7: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. if (chown (buf, 0, 3) || chmod (buf, 0600)) data/mingetty-1.08/mingetty.c:147:28: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chown (buf, 0, 3) || chmod (buf, 0600)) data/mingetty-1.08/mingetty.c:153:7: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. if (chown (buf, 0, 3) || chmod (buf, 0600)) data/mingetty-1.08/mingetty.c:153:28: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chown (buf, 0, 3) || chmod (buf, 0600)) data/mingetty-1.08/mingetty.c:168:6: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. if (chown (buf, 0, 0) || chmod (buf, 0600)) data/mingetty-1.08/mingetty.c:168:27: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chown (buf, 0, 0) || chmod (buf, 0600)) data/mingetty-1.08/mingetty.c:146:3: [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 (buf, &tty[3]); data/mingetty-1.08/mingetty.c:152:3: [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 (buf, &tty[3]); data/mingetty-1.08/mingetty.c:476:2: [4] (shell) execl: 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. execl (loginprog, loginprog, autologin? "-f" : "--", logname, NULL); data/mingetty-1.08/mingetty.c:413:14: [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 ((c = getopt_long (argc, argv, "a:p:d:l:n:w:r:", long_options, data/mingetty-1.08/mingetty.c:462:7: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if (chroot (ch_root)) data/mingetty-1.08/mingetty.c:53: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 hn[MAXHOSTNAMELEN + 1]; data/mingetty-1.08/mingetty.c:140: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[40]; data/mingetty-1.08/mingetty.c:145:3: [2] (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 string. strcpy (buf, "/dev/vcs"); data/mingetty-1.08/mingetty.c:151:3: [2] (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 string. strcpy (buf, "/dev/vcsa"); data/mingetty-1.08/mingetty.c:163:3: [2] (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 string. strcpy (buf, "/dev/"); data/mingetty-1.08/mingetty.c:183:12: [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 (buf, O_RDWR, 0)) < 0) data/mingetty-1.08/mingetty.c:198:13: [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 (buf, O_RDWR, 0)) != 0) data/mingetty-1.08/mingetty.c:251:4: [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 buff[20]; data/mingetty-1.08/mingetty.c:303:28: [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 (noissue == 0 && (fd = fopen ("/etc/issue", "r"))) { data/mingetty-1.08/mingetty.c:422:12: [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). delay = atoi (optarg); data/mingetty-1.08/mingetty.c:428: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). priority = atoi (optarg); data/mingetty-1.08/mingetty.c:117:7: [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 (x) > sizeof (ut.ut_id)) data/mingetty-1.08/mingetty.c:118:9: [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). x += strlen (x) - sizeof (ut.ut_id); data/mingetty-1.08/mingetty.c:119:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (ut.ut_id, x, sizeof (ut.ut_id)); data/mingetty-1.08/mingetty.c:122:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy (ut.ut_user, "LOGIN", sizeof (ut.ut_user)); data/mingetty-1.08/mingetty.c:123:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (ut.ut_line, tty, sizeof (ut.ut_line)); data/mingetty-1.08/mingetty.c:160:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (buf, tty, sizeof(buf)-1); data/mingetty-1.08/mingetty.c:164:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat (buf, tty, sizeof(buf)-strlen(buf)-1); data/mingetty-1.08/mingetty.c:164: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). strncat (buf, tty, sizeof(buf)-strlen(buf)-1); data/mingetty-1.08/mingetty.c:304:15: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((c = getc (fd)) != EOF) { data/mingetty-1.08/mingetty.c:306:26: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). output_special_char (getc (fd)); data/mingetty-1.08/mingetty.c:314:3: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). getc (stdin); data/mingetty-1.08/mingetty.c:344:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read (0, &c, 1) < 1) { ANALYSIS SUMMARY: Hits = 34 Lines analyzed = 480 in approximately 0.02 seconds (19595 lines/second) Physical Source Lines of Code (SLOC) = 383 Hits@level = [0] 14 [1] 12 [2] 11 [3] 2 [4] 3 [5] 6 Hits@level+ = [0+] 48 [1+] 34 [2+] 22 [3+] 11 [4+] 9 [5+] 6 Hits/KSLOC@level+ = [0+] 125.326 [1+] 88.7728 [2+] 57.4413 [3+] 28.7206 [4+] 23.4987 [5+] 15.6658 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.