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/randtype-1.13/randtype.c Examining data/randtype-1.13/randtype.h FINAL RESULTS: data/randtype-1.13/randtype.c:412:8: [5] (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. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(s, src, LINE_MAX - 1); data/randtype-1.13/randtype.c:418:8: [5] (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. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(s, src, LINE_MAX - 1); data/randtype-1.13/randtype.c:165:26: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. i = (1 + (int) (ms * random() / (RAND_MAX + 1.0))) * mult; data/randtype-1.13/randtype.c:190:32: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. i = (1 + (int) (94.0 * random() / (RAND_MAX + 1.0))) + 32; data/randtype-1.13/randtype.c:207:30: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. return((1 + (int) (max * random() / (RAND_MAX + 1.0)))); data/randtype-1.13/randtype.c:535:19: [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, "m:vhr:q:t:n:w:d:c:kl")) != EOF) { data/randtype-1.13/randtype.c:642:5: [3] (random) srandom: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srandom(getpid()); data/randtype-1.13/randtype.c:644:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(getpid()); data/randtype-1.13/randtype.c:279:14: [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). *mult = atoi(s); data/randtype-1.13/randtype.c:310:9: [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 (p0, repl, repl_len); /* Insert replacement.*/ data/randtype-1.13/randtype.c:318:5: [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 (p0, repl, repl_len); /* Final replacement.*/ data/randtype-1.13/randtype.c:365: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(filename, "r")) == NULL) { data/randtype-1.13/randtype.c:411:8: [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. sprintf(src, "%c", tmp[i]); data/randtype-1.13/randtype.c:417:8: [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. sprintf(src, "%c", i); data/randtype-1.13/randtype.c:523: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 progname[NAME_MAX], tmp[NAME_MAX]; data/randtype-1.13/randtype.c:549:17: [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). mistakes = atoi(tmp); data/randtype-1.13/randtype.c:592:13: [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). quit = atoi(tmp); data/randtype-1.13/randtype.h:50:1: [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 nowait[137], wait[137]; data/randtype-1.13/randtype.h:51:1: [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 dumpstr[64]; data/randtype-1.13/randtype.c:224:18: [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 (randint(strlen(str)) == n) { data/randtype-1.13/randtype.c:271:18: [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 (i = 0; i < strlen(s); i++) { data/randtype-1.13/randtype.c:292: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). size_t find_len = strlen(find); data/randtype-1.13/randtype.c:293: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). size_t repl_len = strlen(repl); data/randtype-1.13/randtype.c:303:33: [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). memmove (p0 + dist, p0, strlen(str) - (p0 - str) + 1); data/randtype-1.13/randtype.c:387:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(s, x, LINE_MAX - 1); data/randtype-1.13/randtype.c:401:24: [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 (i = 0; i < (strlen(s) - strlen(tmp)); i++) data/randtype-1.13/randtype.c:401: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). for (i = 0; i < (strlen(s) - strlen(tmp)); i++) data/randtype-1.13/randtype.c:410:20: [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 (i = strlen(dumpstr); i < strlen(tmp); i++) { data/randtype-1.13/randtype.c:410: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). for (i = strlen(dumpstr); i < strlen(tmp); i++) { data/randtype-1.13/randtype.c:430: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). i = strlen(tmp) + strlen(dumpstr); data/randtype-1.13/randtype.c:430: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). i = strlen(tmp) + strlen(dumpstr); data/randtype-1.13/randtype.c:432: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). i = strlen(tmp); data/randtype-1.13/randtype.c:434: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). for (i = i; i < strlen(p); i++) data/randtype-1.13/randtype.c:481: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). i = strlen(find) + 1; data/randtype-1.13/randtype.c:493: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). i = strlen(repl) + 1; data/randtype-1.13/randtype.c:544: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). for (i = 0; i < strlen(tmp); i++) { data/randtype-1.13/randtype.c:564:52: [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 ((optarg[0] != ',' && optarg[0] != '.') || strlen(optarg) < 2) data/randtype-1.13/randtype.c:587: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). for (i = 0; i < strlen(tmp); i++) { ANALYSIS SUMMARY: Hits = 38 Lines analyzed = 721 in approximately 0.03 seconds (25219 lines/second) Physical Source Lines of Code (SLOC) = 546 Hits@level = [0] 30 [1] 19 [2] 11 [3] 6 [4] 0 [5] 2 Hits@level+ = [0+] 68 [1+] 38 [2+] 19 [3+] 8 [4+] 2 [5+] 2 Hits/KSLOC@level+ = [0+] 124.542 [1+] 69.5971 [2+] 34.7985 [3+] 14.652 [4+] 3.663 [5+] 3.663 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.