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/secure-delete-3.1/config.h Examining data/secure-delete-3.1/sdel-lib.c Examining data/secure-delete-3.1/sdel-lib.h Examining data/secure-delete-3.1/sdel-mod.c Examining data/secure-delete-3.1/sdel.h Examining data/secure-delete-3.1/sfill.c Examining data/secure-delete-3.1/smem.c Examining data/secure-delete-3.1/sswap.c Examining data/secure-delete-3.1/srm.c FINAL RESULTS: data/secure-delete-3.1/srm.c:100:24: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. (void) chmod(filename, 0700); /* ignore permission errors */ data/secure-delete-3.1/srm.c:114:25: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. (void) chmod(".", 0700); /* ignore permission errors */ data/secure-delete-3.1/srm.c:158:20: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. (void) chmod(filename, 0600); /* ignore errors */ data/secure-delete-3.1/sdel-lib.c:260:5: [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(newname, filename); // not a buffer overflow as it has got the exact length data/secure-delete-3.1/sdel-lib.c:273:11: [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(newname, filename); data/secure-delete-3.1/sdel-lib.c:277:8: [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(newname, filename); data/secure-delete-3.1/sdel-lib.c:316:5: [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(template, loc); data/secure-delete-3.1/sdel-lib.c:327:13: [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(array[i], template); data/secure-delete-3.1/sdel-mod.c:106:5: [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(newname, filename); // not a buffer overflow as it has got the exact length data/secure-delete-3.1/sdel-mod.c:125:11: [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(newname, filename); data/secure-delete-3.1/sdel-mod.c:129:8: [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(newname, filename); data/secure-delete-3.1/sfill.c:137:8: [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(newname, argv[loop]); // can not overflow data/secure-delete-3.1/srm.c:276:9: [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(rmfile, argv[loop]); data/secure-delete-3.1/sdel-lib.c:108: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()+getuid()+getgid()) ^ time(0) ); data/secure-delete-3.1/sfill.c:104:18: [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. result = getopt(argc, argv, "fFiIlLsSvVzZ"); data/secure-delete-3.1/sfill.c:143:6: [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()+getuid()); data/secure-delete-3.1/smem.c:173:18: [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. result = getopt(argc, argv, "FfLlSsVvZz"); data/secure-delete-3.1/srm.c:214:18: [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. result = getopt(argc, argv, "DdFfLlRrSsVvZz"); data/secure-delete-3.1/sswap.c:86:18: [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. result = getopt(argc, argv, "FfJ:j:LlSsVvZz"); data/secure-delete-3.1/sdel-lib.c:67:22: [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. void __sdel_fill_buf(char pattern[3], unsigned long bufsize, char *buf) { data/secure-delete-3.1/sdel-lib.c:112:26: [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 ((devrandom = fopen(RANDOM_DEVICE, "r")) != NULL) data/secure-delete-3.1/sdel-lib.c:150: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 buf[65535]; data/secure-delete-3.1/sdel-lib.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 newname[strlen(filename) + 1]; data/secure-delete-3.1/sdel-lib.c:256:18: [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(filename, O_WRONLY | O_TRUNC | slow)) >= 0) data/secure-delete-3.1/sdel-lib.c:319:5: [2] (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). Risk is low because the source is a constant string. strcat(template, "xxxxxxxx.xxx"); data/secure-delete-3.1/sdel-lib.c:323: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 (open(template, O_CREAT | O_EXCL | O_WRONLY, 0600) < 0) data/secure-delete-3.1/sdel-lib.h:23:10: [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. unsigned char write_modes[27][3] = { data/secure-delete-3.1/sdel-lib.h:32:10: [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. unsigned char std_array_ff[3] = "\xff\xff\xff"; data/secure-delete-3.1/sdel-lib.h:33:10: [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. unsigned char std_array_00[3] = "\x00\x00\x00"; data/secure-delete-3.1/sdel-mod.c:49:10: [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. unsigned char write_modes[27][3] = { data/secure-delete-3.1/sdel-mod.c:59:10: [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. unsigned char std_array[3] = "\xff\xff\xff"; data/secure-delete-3.1/sdel-mod.c:76: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 buf[BLOCKSIZE]; data/secure-delete-3.1/sdel-mod.c:100: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 newname[strlen(filename) + 1]; // just in kernelspace data/secure-delete-3.1/sdel-mod.c:150:22: [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 void fill_buf(char pattern[3]) data/secure-delete-3.1/sdel.h:31:29: [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. extern void __sdel_fill_buf(char pattern[3], unsigned long bufsize, char *buf); data/secure-delete-3.1/sfill.c:94: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 type[15] = "random"; data/secure-delete-3.1/sfill.c:133:15: [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. if (zero) strcpy(type, "zero"); data/secure-delete-3.1/sfill.c:136: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 newname[strlen(argv[loop]) + 16]; data/secure-delete-3.1/sfill.c:149:13: [2] (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). Risk is low because the source is a constant string. strcat(newname, "oooooooo.ooo"); data/secure-delete-3.1/sfill.c:198:31: [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(newname, O_RDWR | O_EXCL | O_CREAT | O_LARGEFILE | slow, 0600 )) < 0) data/secure-delete-3.1/sfill.c:205:35: [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(newname, O_WRONLY | O_TRUNC)) >= 0) data/secure-delete-3.1/smem.c:38: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 buf[BLOCKSIZE+2]; data/secure-delete-3.1/smem.c:57:14: [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. unsigned char write_modes[27][3] = { data/secure-delete-3.1/smem.c:69:14: [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. unsigned char buffers[27][BLOCKSIZE+2]; data/secure-delete-3.1/smem.c:83:26: [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 ((devrandom = fopen(RANDOM_DEVICE, "r")) != NULL) data/secure-delete-3.1/smem.c:123:13: [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(buffers[turn], buf, BLOCKSIZE); data/secure-delete-3.1/smem.c:134:21: [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(ptr, buffers[turn-5], BLOCKSIZE); data/secure-delete-3.1/smem.c:137:21: [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(ptr, buf, BLOCKSIZE); data/secure-delete-3.1/srm.c:88:6: [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 current_dir[4097]; data/secure-delete-3.1/srm.c:155:19: [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(filename, O_RDWR | O_LARGEFILE | slow)) < 0) { data/secure-delete-3.1/srm.c:159:23: [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(filename, O_RDWR | O_LARGEFILE | slow)) < 0) data/secure-delete-3.1/srm.c:252:9: [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 type[15] = "random"; data/secure-delete-3.1/srm.c:253:19: [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. if (zero) strcpy(type, "zero"); data/secure-delete-3.1/srm.c:275:9: [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 rmfile[strlen(argv[loop]) + 1]; data/secure-delete-3.1/sswap.c:93:32: [2] (integer) atol: 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). case 'j' : start = atol(optarg); data/secure-delete-3.1/sswap.c:125: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). if ((fd = open (filename, O_RDWR | O_LARGEFILE | slow)) < 0) { data/secure-delete-3.1/sswap.c:138:9: [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 type[15] = "random"; data/secure-delete-3.1/sswap.c:139:19: [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. if (zero) strcpy(type, "zero"); data/secure-delete-3.1/sdel-lib.c:91: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 (i = strlen(filename) - 1; data/secure-delete-3.1/sdel-lib.c:251:17: [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 newname[strlen(filename) + 1]; data/secure-delete-3.1/sdel-lib.c:307:29: [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 *template = malloc(strlen(loc) + 16); data/secure-delete-3.1/sdel-lib.c:317:13: [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 (loc[strlen(loc) - 1] != '/') data/secure-delete-3.1/sdel-lib.c:318:9: [1] (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). Risk is low because the source is a constant character. strcat(template, "/"); data/secure-delete-3.1/sdel-lib.c:326:31: [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). array[i] = malloc(strlen(template)); data/secure-delete-3.1/sdel-mod.c:82: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 (i = strlen(filename) - 1; data/secure-delete-3.1/sdel-mod.c:100:17: [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 newname[strlen(filename) + 1]; // just in kernelspace data/secure-delete-3.1/sdel-mod.c:116:35: [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( brk_orig((void*) mmm + strlen(filename) + 1 ) < 0) { data/secure-delete-3.1/sdel-mod.c:121:40: [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). copy_to_user(ul_newname,newname,strlen(newname)); data/secure-delete-3.1/sdel-mod.c:335: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). size = strlen(kl_filename); data/secure-delete-3.1/sfill.c:136: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). char newname[strlen(argv[loop]) + 16]; data/secure-delete-3.1/sfill.c:145: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 (newname[strlen(newname)-1] != DIR_SEPERATOR) data/secure-delete-3.1/sfill.c:146:16: [1] (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). Risk is low because the source is a constant character. strcat(newname, "/"); data/secure-delete-3.1/sfill.c:153: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). for (counter = strlen(newname)-1; data/secure-delete-3.1/srm.c:275: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). char rmfile[strlen(argv[loop]) + 1]; ANALYSIS SUMMARY: Hits = 74 Lines analyzed = 1767 in approximately 0.08 seconds (23454 lines/second) Physical Source Lines of Code (SLOC) = 1316 Hits@level = [0] 129 [1] 16 [2] 39 [3] 6 [4] 10 [5] 3 Hits@level+ = [0+] 203 [1+] 74 [2+] 58 [3+] 19 [4+] 13 [5+] 3 Hits/KSLOC@level+ = [0+] 154.255 [1+] 56.231 [2+] 44.0729 [3+] 14.4377 [4+] 9.87842 [5+] 2.27964 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.