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/dbench-4.0/child.c Examining data/dbench-4.0/dbench.c Examining data/dbench-4.0/dbench.h Examining data/dbench-4.0/fileio.c Examining data/dbench-4.0/io.c Examining data/dbench-4.0/proto.h Examining data/dbench-4.0/snprintf.c Examining data/dbench-4.0/sockio.c Examining data/dbench-4.0/socklib.c Examining data/dbench-4.0/system.c Examining data/dbench-4.0/tbench_srv.c Examining data/dbench-4.0/util.c FINAL RESULTS: data/dbench-4.0/snprintf.c:779:6: [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. int vsnprintf (char *str, size_t count, const char *fmt, va_list args) data/dbench-4.0/snprintf.c:794:6: [4] (format) snprintf: 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. int snprintf(char *str,size_t count,const char *fmt,...) data/dbench-4.0/snprintf.c:800:8: [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. ret = vsnprintf(str, count, fmt, ap); data/dbench-4.0/snprintf.c:816:8: [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. ret = vsnprintf(NULL, 0, format, ap2); data/dbench-4.0/snprintf.c:824:8: [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. ret = vsnprintf(*ptr, ret+1, format, ap2); data/dbench-4.0/snprintf.c:848:6: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. int sprintf(char *str,const char *fmt,...); data/dbench-4.0/snprintf.c:910:13: [4] (format) snprintf: 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. int l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]); data/dbench-4.0/snprintf.c:911:13: [4] (format) snprintf: 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. int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); data/dbench-4.0/snprintf.c:912:4: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf (buf2, fp_fmt[x], fp_nums[y]); data/dbench-4.0/snprintf.c:928:13: [4] (format) snprintf: 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. int l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]); data/dbench-4.0/snprintf.c:929:13: [4] (format) snprintf: 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. int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); data/dbench-4.0/snprintf.c:930:4: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf (buf2, int_fmt[x], int_nums[y]); data/dbench-4.0/snprintf.c:946:13: [4] (format) snprintf: 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. int l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]); data/dbench-4.0/snprintf.c:947:13: [4] (format) snprintf: 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. int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); data/dbench-4.0/snprintf.c:948:4: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf (buf2, str_fmt[x], str_vals[y]); data/dbench-4.0/fileio.c:120:7: [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. if (random() % 10 < 2) { data/dbench-4.0/tbench_srv.c:96:14: [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 ((c = getopt(argc, argv, "t:")) != -1) { data/dbench-4.0/child.c:166: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 line[1024], fname[1024], fname2[1024]; data/dbench-4.0/child.c:185:6: [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). f = fopen(loadfile, "r"); data/dbench-4.0/dbench.c:55:11: [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 ((f = fopen(options.loadfile, "rt")) != NULL) data/dbench-4.0/dbench.c:455:19: [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). options.nprocs = atoi(extra_argv[0]); data/dbench-4.0/fileio.c:62: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). dir_fd = open(copy_name, O_RDONLY); data/dbench-4.0/fileio.c:87: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[44]; data/dbench-4.0/fileio.c:102: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 buf[44]; data/dbench-4.0/fileio.c:116: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 buf[44]; data/dbench-4.0/fileio.c:124: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(buf, &tv, sizeof(tv)); data/dbench-4.0/fileio.c:284:7: [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). fd = open(fname, flags, 0600); data/dbench-4.0/fileio.c:287:8: [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). fd = open(fname, flags, 0600); data/dbench-4.0/fileio.c:345:24: [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. if (c == ((unsigned char *)buf)[0]) { data/dbench-4.0/fileio.c:350:25: [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. } else if (((unsigned char *)buf)[0] == 0) { data/dbench-4.0/io.c:27: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. static char buf[70000]; data/dbench-4.0/io.c:66:7: [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). fd = open(fname, flags, 0600); data/dbench-4.0/snprintf.c:469: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 convert[20]; data/dbench-4.0/snprintf.c:622: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 iconvert[311]; data/dbench-4.0/snprintf.c:623: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 fconvert[311]; data/dbench-4.0/snprintf.c:852: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 buf1[1024]; data/dbench-4.0/snprintf.c:853: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 buf2[1024]; data/dbench-4.0/snprintf.c:971:4: [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(buf2, "%1.1f", r); data/dbench-4.0/sockio.c:24: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[70000]; data/dbench-4.0/socklib.c:72: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(&sock_out.sin_addr, hp->h_addr, hp->h_length); data/dbench-4.0/socklib.c:139: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 tok[200]; data/dbench-4.0/socklib.c:151:12: [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). value = atoi(p+1); data/dbench-4.0/tbench_srv.c:27: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[70000]; data/dbench-4.0/util.c:89:3: [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(p, insert, li); data/dbench-4.0/child.c:208: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). line[strlen(line)-1] = 0; data/dbench-4.0/dbench.c:321:3: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(100*1000); data/dbench-4.0/fileio.c:621:2: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(usec); data/dbench-4.0/io.c:132:2: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(ftable[i].fd, buf, size); data/dbench-4.0/snprintf.c:365: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). max = strlen(strvalue); data/dbench-4.0/sockio.c:90: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). do_packets(child, 39+2+strlen(fname)*2+2, 39); data/dbench-4.0/sockio.c:97: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). do_packets(child, 39+2+strlen(dname)*2+2, 39); data/dbench-4.0/sockio.c:104: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). do_packets(child, 39+2+strlen(fname)*2+2, 39); data/dbench-4.0/sockio.c:116: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). do_packets(child, 70+2+strlen(fname)*2+2, 39+12*4); data/dbench-4.0/sockio.c:155:34: [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). do_packets(child, 39+8+2*strlen(old)+2*strlen(new), 39); data/dbench-4.0/sockio.c:155: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). do_packets(child, 39+8+2*strlen(old)+2*strlen(new), 39); data/dbench-4.0/sockio.c:172: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). do_packets(child, 39+16+2*strlen(fname), 39+32); data/dbench-4.0/sockio.c:199: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). do_packets(child, 39+20+strlen(fname)*2, 39+90*count); data/dbench-4.0/sockio.c:249:2: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(usec); data/dbench-4.0/util.c:81:7: [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). ls = strlen(s); data/dbench-4.0/util.c:82:7: [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). lp = strlen(pattern); data/dbench-4.0/util.c:83:7: [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). li = strlen(insert); ANALYSIS SUMMARY: Hits = 61 Lines analyzed = 3782 in approximately 0.14 seconds (26681 lines/second) Physical Source Lines of Code (SLOC) = 2880 Hits@level = [0] 102 [1] 17 [2] 27 [3] 2 [4] 15 [5] 0 Hits@level+ = [0+] 163 [1+] 61 [2+] 44 [3+] 17 [4+] 15 [5+] 0 Hits/KSLOC@level+ = [0+] 56.5972 [1+] 21.1806 [2+] 15.2778 [3+] 5.90278 [4+] 5.20833 [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.