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/lua-lpty-1.0.1/lpty.c FINAL RESULTS: data/lua-lpty-1.0.1/lpty.c:226:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "%s (%p)", LPTY, pty); data/lua-lpty-1.0.1/lpty.c:264:2: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. vsnprintf(buf, BUFSIZ, msg, ap); data/lua-lpty-1.0.1/lpty.c:414:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(c, "%s=%s", k, v); data/lua-lpty-1.0.1/lpty.c:482:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(pbuf, "%s/%s", p, filename); data/lua-lpty-1.0.1/lpty.c:489:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(pbuf, "%s/%s", p, filename); data/lua-lpty-1.0.1/lpty.c:735: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(buf, c); data/lua-lpty-1.0.1/lpty.c:472:21: [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. char *protopath = getenv("PATH"); data/lua-lpty-1.0.1/lpty.c:221: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[TOSTRING_BUFSIZ]; data/lua-lpty-1.0.1/lpty.c:263: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/lua-lpty-1.0.1/lpty.c:354:11: [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). sfd = open(ttyn, O_RDWR); data/lua-lpty-1.0.1/lpty.c:860: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[READER_BUFSIZ]; // should probably be more flexible data/lua-lpty-1.0.1/lpty.c:223: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(LPTY) + (sizeof(void*) * 2) + 2 + 4 > TOSTRING_BUFSIZ) data/lua-lpty-1.0.1/lpty.c:413: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). c = malloc(strlen(k) + 1 + strlen(v) + 1); data/lua-lpty-1.0.1/lpty.c:413: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). c = malloc(strlen(k) + 1 + strlen(v) + 1); data/lua-lpty-1.0.1/lpty.c:475:23: [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 *pbuf = malloc(strlen(protopath) + strlen(filename) + 2); data/lua-lpty-1.0.1/lpty.c:475: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 *pbuf = malloc(strlen(protopath) + strlen(filename) + 2); data/lua-lpty-1.0.1/lpty.c:731: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). if (strlen(c) >= buflen) { data/lua-lpty-1.0.1/lpty.c:732: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). buflen += strlen(c); data/lua-lpty-1.0.1/lpty.c:867:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). readn = read(pty->m_fd, buf, READER_BUFSIZ); data/lua-lpty-1.0.1/lpty.c:930: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). written = write(pty->m_fd, data, strlen(data)); data/lua-lpty-1.0.1/lpty.c:961:11: [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 l = strlen(mode); ANALYSIS SUMMARY: Hits = 21 Lines analyzed = 1079 in approximately 0.03 seconds (31606 lines/second) Physical Source Lines of Code (SLOC) = 546 Hits@level = [0] 2 [1] 10 [2] 4 [3] 1 [4] 6 [5] 0 Hits@level+ = [0+] 23 [1+] 21 [2+] 11 [3+] 7 [4+] 6 [5+] 0 Hits/KSLOC@level+ = [0+] 42.1245 [1+] 38.4615 [2+] 20.1465 [3+] 12.8205 [4+] 10.989 [5+] 0 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.