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/electric-fence-2.2.5/print.c Examining data/electric-fence-2.2.5/efence.c Examining data/electric-fence-2.2.5/eftest.c Examining data/electric-fence-2.2.5/page.c Examining data/electric-fence-2.2.5/tstheap.c Examining data/electric-fence-2.2.5/efence.h FINAL RESULTS: data/electric-fence-2.2.5/efence.c:924:7: [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). char *strcat(char *d, const char *s) data/electric-fence-2.2.5/efence.c:926:2: [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(d+strlen(d), s); data/electric-fence-2.2.5/efence.c:253:31: [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. if ( (string = getenv("EF_DISABLE_BANNER")) != 0 ) data/electric-fence-2.2.5/efence.c:290:18: [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. if ( (string = getenv("EF_ALIGNMENT")) != 0 ) data/electric-fence-2.2.5/efence.c:301:18: [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. if ( (string = getenv("EF_PROTECT_BELOW")) != 0 ) data/electric-fence-2.2.5/efence.c:312:18: [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. if ( (string = getenv("EF_PROTECT_FREE")) != 0 ) data/electric-fence-2.2.5/efence.c:322:18: [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. if ( (string = getenv("EF_ALLOW_MALLOC_0")) != 0 ) data/electric-fence-2.2.5/efence.c:332:18: [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. if ( (string = getenv("EF_FILL")) != 0) data/electric-fence-2.2.5/tstheap.c:14:25: [3] (random) drand48: 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. extern C_LINKAGE double drand48(void); /* For pre-ANSI C systems */ data/electric-fence-2.2.5/tstheap.c:33:1: [3] (random) drand48: 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. drand48(void) data/electric-fence-2.2.5/tstheap.c:35:10: [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 (random() / (double)ULONG_MAX); data/electric-fence-2.2.5/tstheap.c:49:34: [3] (random) drand48: 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. void * * element = &pool[(int)(drand48() * POOL_SIZE)]; data/electric-fence-2.2.5/tstheap.c:50:27: [3] (random) drand48: 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. size_t size = (size_t)(drand48() * (LARGEST_BUFFER + 1)); data/electric-fence-2.2.5/efence.c:254:44: [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). EF_DISABLE_BANNER = atoi(string); data/electric-fence-2.2.5/efence.c:291:27: [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). EF_ALIGNMENT = (size_t)atoi(string); data/electric-fence-2.2.5/efence.c:302:24: [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). EF_PROTECT_BELOW = (atoi(string) != 0); data/electric-fence-2.2.5/efence.c:313:23: [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). EF_PROTECT_FREE = (atoi(string) != 0); data/electric-fence-2.2.5/efence.c:323:25: [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). EF_ALLOW_MALLOC_0 = (atoi(string) != 0); data/electric-fence-2.2.5/efence.c:333:30: [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). EF_FILL = (unsigned char) atoi(string); data/electric-fence-2.2.5/efence.c:366: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. = ((char *)slot[0].internalAddress) + slot[0].internalSize; data/electric-fence-2.2.5/efence.c:417:2: [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(newAllocation, allocationList, allocationListSize); data/electric-fence-2.2.5/efence.c:418:13: [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. memset(&(((char *)newAllocation)[allocationListSize]), 0, bytesPerPage); data/electric-fence-2.2.5/efence.c:873: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(newBuffer, oldBuffer, size); data/electric-fence-2.2.5/efence.c:880:15: [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. memset(&(((char *)newBuffer)[size]), 0, newSize - size); data/electric-fence-2.2.5/page.c:40:3: [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 err_message[128]; data/electric-fence-2.2.5/page.c:104:15: [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). devZeroFd = open("/dev/zero", O_RDWR); data/electric-fence-2.2.5/print.c:36: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 buffer[NUMBER_BUFFER_SIZE]; data/electric-fence-2.2.5/tstheap.c:46: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). duration = atoi(argv[1]); data/electric-fence-2.2.5/efence.c:662:1: [1] (free) memalign: On some systems (though not Linux-based systems) an attempt to free() results from memalign() may fail. This may, on a few systems, be exploitable. Also note that memalign() may not check that the boundary parameter is correct (CWE-676). Use posix_memalign instead (defined in POSIX's 1003.1d). Don't switch to valloc(); it is marked as obsolete in BSD 4.3, as legacy in SUSv2, and is no longer defined in SUSv3. In some cases, malloc()'s alignment may be sufficient. memalign(size_t alignment, size_t userSize) data/electric-fence-2.2.5/efence.c:687:14: [1] (free) memalign: On some systems (though not Linux-based systems) an attempt to free() results from memalign() may fail. This may, on a few systems, be exploitable. Also note that memalign() may not check that the boundary parameter is correct (CWE-676). Use posix_memalign instead (defined in POSIX's 1003.1d). Don't switch to valloc(); it is marked as obsolete in BSD 4.3, as legacy in SUSv2, and is no longer defined in SUSv3. In some cases, malloc()'s alignment may be sufficient. void *ptr = memalign (alignment, size); data/electric-fence-2.2.5/efence.c:895:9: [1] (free) memalign: On some systems (though not Linux-based systems) an attempt to free() results from memalign() may fail. This may, on a few systems, be exploitable. Also note that memalign() may not check that the boundary parameter is correct (CWE-676). Use posix_memalign instead (defined in POSIX's 1003.1d). Don't switch to valloc(); it is marked as obsolete in BSD 4.3, as legacy in SUSv2, and is no longer defined in SUSv3. In some cases, malloc()'s alignment may be sufficient. return memalign(EF_ALIGNMENT, size); data/electric-fence-2.2.5/efence.c:915:9: [1] (free) memalign: On some systems (though not Linux-based systems) an attempt to free() results from memalign() may fail. This may, on a few systems, be exploitable. Also note that memalign() may not check that the boundary parameter is correct (CWE-676). Use posix_memalign instead (defined in POSIX's 1003.1d). Don't switch to valloc(); it is marked as obsolete in BSD 4.3, as legacy in SUSv2, and is no longer defined in SUSv3. In some cases, malloc()'s alignment may be sufficient. return memalign(bytesPerPage, size); data/electric-fence-2.2.5/efence.c:926: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). strcpy(d+strlen(d), s); data/electric-fence-2.2.5/eftest.c:226: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). write(2, diag->explanation, strlen(diag->explanation)); data/electric-fence-2.2.5/print.c:93: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). length = strlen(string); ANALYSIS SUMMARY: Hits = 35 Lines analyzed = 1651 in approximately 0.06 seconds (25447 lines/second) Physical Source Lines of Code (SLOC) = 980 Hits@level = [0] 0 [1] 7 [2] 15 [3] 11 [4] 2 [5] 0 Hits@level+ = [0+] 35 [1+] 35 [2+] 28 [3+] 13 [4+] 2 [5+] 0 Hits/KSLOC@level+ = [0+] 35.7143 [1+] 35.7143 [2+] 28.5714 [3+] 13.2653 [4+] 2.04082 [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.