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/tapecalc-20070214/add.c Examining data/tapecalc-20070214/add.h Examining data/tapecalc-20070214/curses.c Examining data/tapecalc-20070214/screen.h FINAL RESULTS: data/tapecalc-20070214/add.c:194:12: [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). return strcpy(malloc((unsigned) (strlen(src) + 1)), src); data/tapecalc-20070214/add.c:393:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. (void) sprintf(s, ".%s", &bfr[len]); data/tapecalc-20070214/add.c:632:9: [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. (void) fprintf(stderr, format, msg, arg); data/tapecalc-20070214/add.c:664:5: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. && access(path, 02) != 0 data/tapecalc-20070214/add.c:689:12: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. (void) sprintf(buffer, "Writing results to \"%s\"", path); data/tapecalc-20070214/add.c:716:12: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. (void) sprintf(buffer, "Wrote %d line%s to \"%s\"", data/tapecalc-20070214/add.c:728:34: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (Fexists(path) != TRUE || access(path, 04) != 0) data/tapecalc-20070214/add.c:1113:12: [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). (void) strcpy(buffer, np->txt != 0 ? np->txt : ""); data/tapecalc-20070214/add.c:1905:24: [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). register char *s = strcpy(temp, program); data/tapecalc-20070214/add.c:1923:10: [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). s = strcpy(temp + l, program); data/tapecalc-20070214/add.c:1924:10: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(temp, 5) == 0) { data/tapecalc-20070214/add.c:1934:19: [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). s = PathLeaf(strcpy(s, program)); data/tapecalc-20070214/curses.c:342:5: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. vsprintf(msg, format, ap); data/tapecalc-20070214/curses.c:390:5: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. vsprintf(msg, format, ap); data/tapecalc-20070214/add.c:1914:15: [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 *path = getenv("PATH"); data/tapecalc-20070214/add.c:2103:1: [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. getopt(int argc, char **argv, char *opts) data/tapecalc-20070214/add.c:2150:17: [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 ((j = getopt(argc, argv, "hi:o:p:V")) != EOF) data/tapecalc-20070214/add.c:368: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 bfr[MAXBFR], *s = dst; data/tapecalc-20070214/add.c:376:9: [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. (void) strcpy(s, " ** overflow"); data/tapecalc-20070214/add.c:378:9: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. (void) sprintf(bfr, "%0*.0f", len_frac, val); data/tapecalc-20070214/add.c:404: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 bfr[MAXBFR]; data/tapecalc-20070214/add.c:565: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 buffer[BUFSIZ]; data/tapecalc-20070214/add.c:571:9: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. (void) sprintf(buffer, "%d of %d", seq, CountData(last)); data/tapecalc-20070214/add.c:680:34: [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). FILE *fp = (path && *path) ? fopen(path, "w") : 0; data/tapecalc-20070214/add.c:681: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 buffer[MAXBFR]; data/tapecalc-20070214/add.c:825:17: [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). scriptFP = fopen(*scriptv, "r"); data/tapecalc-20070214/add.c:1109: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 buffer[BUFSIZ]; data/tapecalc-20070214/add.c:1169: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 buffer[MAXBFR]; /* current input value */ data/tapecalc-20070214/add.c:1192:13: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. (void) sprintf(buffer, "%0*.0f", len_frac, np->val); data/tapecalc-20070214/add.c:1653: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 buffer[BUFSIZ]; data/tapecalc-20070214/add.c:1815: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 buffer[BUFSIZ]; data/tapecalc-20070214/add.c:1820: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 ((fp = fopen(helpfile, "r")) != 0) { data/tapecalc-20070214/add.c:1840:9: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. (void) sprintf(buffer, "line %d of %d", CountData(np), end); data/tapecalc-20070214/add.c:1904: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 temp[BUFSIZ]; data/tapecalc-20070214/add.c:1938:12: [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. (void) strcpy(s, "add.hlp"); data/tapecalc-20070214/curses.c:334: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 msg[BUFSIZ]; data/tapecalc-20070214/curses.c:386: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 msg[BUFSIZ]; data/tapecalc-20070214/add.c:178: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). register char *end = src + strlen(src); data/tapecalc-20070214/add.c:194:38: [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). return strcpy(malloc((unsigned) (strlen(src) + 1)), src); data/tapecalc-20070214/add.c:379: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). len = strlen(bfr) - len_frac; data/tapecalc-20070214/add.c:385:10: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). (void) strncpy(s, &bfr[j], grp); data/tapecalc-20070214/add.c:572:48: [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). screen_set_position(0, screen_cols_left((int) strlen(buffer))); data/tapecalc-20070214/add.c:789:13: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c = fgetc(scriptFP); data/tapecalc-20070214/add.c:916: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). if (limit > 0 && (int) strlen(buffer) < limit) { data/tapecalc-20070214/add.c:939: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). int len = strlen(buffer); data/tapecalc-20070214/add.c:1047: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). int col = strlen(buffer); data/tapecalc-20070214/add.c:1055:21: [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 (end < (int) strlen(buffer)) data/tapecalc-20070214/add.c:1056: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). offset = strlen(buffer) - end; data/tapecalc-20070214/add.c:1081: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). if ((int) strlen(buffer) < length - 1) data/tapecalc-20070214/add.c:1090:41: [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). col = screen_move_right(col, (int) strlen(buffer)); data/tapecalc-20070214/add.c:1095: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). while (col < (int) strlen(buffer)) data/tapecalc-20070214/add.c:1096:38: [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). col = screen_move_right(col, (int) strlen(buffer)); data/tapecalc-20070214/add.c:1193:12: [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). len = strlen(buffer); data/tapecalc-20070214/add.c:1203:64: [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). screen_set_position(row, (int) (editcols[0] + val_width - strlen(buffer))); data/tapecalc-20070214/add.c:1212: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). col = strlen(buffer); data/tapecalc-20070214/add.c:1245:41: [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). col = screen_move_right(col, (int) strlen(buffer)); data/tapecalc-20070214/add.c:1250: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). while (col < (int) strlen(buffer)) data/tapecalc-20070214/add.c:1251:38: [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). col = screen_move_right(col, (int) strlen(buffer)); data/tapecalc-20070214/add.c:1297: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). if ((int) strlen(buffer) > limit) data/tapecalc-20070214/add.c:1319: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). register int len = strlen(buffer); data/tapecalc-20070214/add.c:1341:41: [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). *len_ = (*buffer == L_PAREN) ? 0 : strlen(buffer); data/tapecalc-20070214/add.c:1841:48: [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). screen_set_position(0, screen_cols_left((int) strlen(buffer))); data/tapecalc-20070214/add.c:1886:14: [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). for (n = strlen(path); n > 0; n--) data/tapecalc-20070214/add.c:1907: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). for (s += strlen(temp); s != temp; s--) ANALYSIS SUMMARY: Hits = 64 Lines analyzed = 3030 in approximately 0.08 seconds (36112 lines/second) Physical Source Lines of Code (SLOC) = 2318 Hits@level = [0] 16 [1] 27 [2] 20 [3] 3 [4] 14 [5] 0 Hits@level+ = [0+] 80 [1+] 64 [2+] 37 [3+] 17 [4+] 14 [5+] 0 Hits/KSLOC@level+ = [0+] 34.5125 [1+] 27.61 [2+] 15.962 [3+] 7.33391 [4+] 6.03969 [5+] 0 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.