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/haveged-1.9.13/contrib/build/havege_sample.c Examining data/haveged-1.9.13/contrib/diags/data_prep.c Examining data/haveged-1.9.13/ent/chisq.c Examining data/haveged-1.9.13/ent/entest.c Examining data/haveged-1.9.13/ent/iso8859.c Examining data/haveged-1.9.13/ent/iso8859.h Examining data/haveged-1.9.13/ent/randtest.c Examining data/haveged-1.9.13/ent/randtest.h Examining data/haveged-1.9.13/nist/cephes-protos.h Examining data/haveged-1.9.13/nist/cephes.c Examining data/haveged-1.9.13/nist/dfft.c Examining data/haveged-1.9.13/nist/matrix.c Examining data/haveged-1.9.13/nist/matrix.h Examining data/haveged-1.9.13/nist/mconf.h Examining data/haveged-1.9.13/nist/nist.c Examining data/haveged-1.9.13/nist/nist.h Examining data/haveged-1.9.13/nist/packtest.c Examining data/haveged-1.9.13/nist/special-functions.c Examining data/haveged-1.9.13/nist/special-functions.h Examining data/haveged-1.9.13/src/cpuid-43.h Examining data/haveged-1.9.13/src/havege.c Examining data/haveged-1.9.13/src/havege.h Examining data/haveged-1.9.13/src/havegecmd.c Examining data/haveged-1.9.13/src/havegecmd.h Examining data/haveged-1.9.13/src/havegecollect.c Examining data/haveged-1.9.13/src/havegecollect.h Examining data/haveged-1.9.13/src/haveged.c Examining data/haveged-1.9.13/src/haveged.h Examining data/haveged-1.9.13/src/havegetest.c Examining data/haveged-1.9.13/src/havegetest.h Examining data/haveged-1.9.13/src/havegetune.c Examining data/haveged-1.9.13/src/havegetune.h Examining data/haveged-1.9.13/src/oneiteration.h FINAL RESULTS: data/haveged-1.9.13/contrib/diags/data_prep.c:98: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). strcat(short_options,cmds[j]); data/haveged-1.9.13/nist/nist.c:36:3: [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). strcat(basedirname, argv[2]); data/haveged-1.9.13/nist/packtest.c:696:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (directory, "%stemplate%d", GetBaseDir(), m); data/haveged-1.9.13/src/havegecmd.c:84:10: [4] (shell) execv: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. ret = execv((const char *)path, argv); data/haveged-1.9.13/src/haveged.c:191:8: [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("/etc/initrd-release", F_OK) >= 0) { data/haveged-1.9.13/src/haveged.c:260: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). strcat(short_options,cmds[j]); data/haveged-1.9.13/src/haveged.c:332:13: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(VERSION_TEXT, HAVEGE_PREP_VERSION); data/haveged-1.9.13/src/haveged.c:723:4: [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. vsnprintf(buffer, sizeof(buffer), format, ap); data/haveged-1.9.13/src/haveged.c:843:4: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, buffer, ap); data/haveged-1.9.13/src/haveged.c:886:7: [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. fprintf(stderr, format, in, src, sz, out); data/haveged-1.9.13/src/havegetune.c:71:25: [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. #define TUNE_DEBUG(...) fprintf(stderr,__VA_ARGS__) data/haveged-1.9.13/contrib/diags/data_prep.c:108:11: [3] (buffer) getopt_long: 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. c = getopt_long (argc, argv, short_options, long_options, NULL); data/haveged-1.9.13/ent/entest.c:171:23: [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, "?c:e:f:m:p:s:t:v")) != -1) { data/haveged-1.9.13/src/havegecmd.c:70:10: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. ret = chroot("."); data/haveged-1.9.13/src/haveged.c:267:11: [3] (buffer) getopt_long: 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. c = getopt_long (argc, argv, short_options, long_options, NULL); data/haveged-1.9.13/contrib/build/havege_sample.c:44: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 status_buf[status_buf_size]; data/haveged-1.9.13/contrib/diags/data_prep.c:86: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 short_options[1+nopts*2]; data/haveged-1.9.13/contrib/diags/data_prep.c:95:35: [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). long_options[i].has_arg = atoi(cmds[j+2]); data/haveged-1.9.13/contrib/diags/data_prep.c:111:28: [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). params.bsize = atoi(optarg); data/haveged-1.9.13/contrib/diags/data_prep.c:120: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). params.options = atoi(optarg); data/haveged-1.9.13/contrib/diags/data_prep.c:131:29: [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). params.repeat = atoi(optarg); data/haveged-1.9.13/contrib/diags/data_prep.c:134:28: [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). params.value = atoi(optarg); data/haveged-1.9.13/contrib/diags/data_prep.c:137:28: [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). params.limit = atoi(optarg); data/haveged-1.9.13/contrib/diags/data_prep.c:140:26: [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). params.cmd = atoi(optarg); data/haveged-1.9.13/contrib/diags/data_prep.c:155:22: [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). params.input = fopen(argv[optind], "rb"); data/haveged-1.9.13/contrib/diags/data_prep.c:164:23: [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). params.output = fopen(params.outpath, "wb"); data/haveged-1.9.13/contrib/diags/data_prep.c:193: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 ibuf[80], *s; data/haveged-1.9.13/ent/entest.c:78: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 failures[512]; data/haveged-1.9.13/ent/entest.c:84:3: [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(failures+offs,"entropy:%f<%f ",ent,params->entropy); data/haveged-1.9.13/ent/entest.c:89:3: [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(failures+offs,"chisqr:%f%% not in %f-%f ",chip,p0,p1); data/haveged-1.9.13/ent/entest.c:93:3: [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(failures+offs,"mean:%f<%f ",mean,params->mean); data/haveged-1.9.13/ent/entest.c:98:3: [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(failures+offs,"pi:%f %f>%f ",montepi,p,params->pi); data/haveged-1.9.13/ent/entest.c:102:3: [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(failures+offs,"sequence:%f>%f ",scc,params->seq); data/haveged-1.9.13/ent/entest.c:217:19: [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, "rb")) == NULL) { data/haveged-1.9.13/ent/iso8859.c:6: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 isoalpha[32] = { data/haveged-1.9.13/ent/iso8859.c:11: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 isoupper[32] = { data/haveged-1.9.13/ent/iso8859.c:16: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 isolower[32] = { data/haveged-1.9.13/ent/iso8859.h:4:17: [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 unsigned char isoalpha[32], isoupper[32], isolower[32]; data/haveged-1.9.13/nist/cephes.c:17: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 *ermsg[7] = { data/haveged-1.9.13/nist/nist.c:14: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 basedirname[FILENAME_MAX+1]; data/haveged-1.9.13/nist/nist.c:41: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 ((fp = fopen(filename, "rb")) == NULL) { data/haveged-1.9.13/nist/packtest.c:88: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 BigArray[BIGSIZE]; data/haveged-1.9.13/nist/packtest.c:125:13: [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). fileout = fopen (C, "w"); data/haveged-1.9.13/nist/packtest.c:274:13: [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). fileout = fopen (C, "a"); data/haveged-1.9.13/nist/packtest.c:685: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 directory[FILENAME_MAX]; data/haveged-1.9.13/nist/packtest.c:697:13: [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 (directory, "r")) == NULL) data/haveged-1.9.13/src/havege.c:301:10: [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(h_sts->n_tests, ps->meters, (H_OLT_PROD_B_P+1) * sizeof(H_UINT)); data/haveged-1.9.13/src/havege.c:601:18: [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). c = atoi(options); data/haveged-1.9.13/src/havege.c:708:17: [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 const char * pa_tests[6] = {"test0","test1","test2","test3","test4","test5"}; data/haveged-1.9.13/src/havege.c:746:17: [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 const char * pb_tests[5] = {"test6a","test6b","test7a","test7b","test8"}; data/haveged-1.9.13/src/havegecmd.c:231: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. unsigned char magic[2], *ptr; data/haveged-1.9.13/src/havegecollect.c:290: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 wkspc[SZH_INIT]; data/haveged-1.9.13/src/havegecollect.c:312: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 **)RESULT)[n] = CODE_PT(p); data/haveged-1.9.13/src/haveged.c:130:36: [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). #define ATOU(a) (unsigned int)atoi(a) data/haveged-1.9.13/src/haveged.c:162: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 short_options[1+nopts*2]; data/haveged-1.9.13/src/haveged.c:257:35: [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). long_options[i].has_arg = atoi(cmds[j+2]); data/haveged-1.9.13/src/haveged.c:341:7: [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 *ptr, message[PATH_MAX+5], answer[2], cmd[2]; data/haveged-1.9.13/src/haveged.c:447:20: [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). else fd_in = fopen(params->sample_in, "rb"); data/haveged-1.9.13/src/haveged.c:509:9: [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). fh = fopen(params->pid_file, "w"); data/haveged-1.9.13/src/haveged.c:526:18: [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). poolsize_fh = fopen(params->poolsize, "rb"); data/haveged-1.9.13/src/haveged.c:531:18: [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). osrel_fh = fopen(params->os_rel, "rb"); data/haveged-1.9.13/src/haveged.c:578:16: [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). random_fd = open(params->random_device, O_RDWR); data/haveged-1.9.13/src/haveged.c:691: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). wm_fh = fopen(params->watermark, "w"); data/haveged-1.9.13/src/haveged.c:704: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 buf[120]; data/haveged-1.9.13/src/haveged.c:719: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 buffer[4096]; data/haveged-1.9.13/src/haveged.c:833: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 buffer[128]; data/haveged-1.9.13/src/haveged.c:865:22: [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). else if (!(fout = fopen (params->sample_out, "wb"))) data/haveged-1.9.13/src/havegetest.c:620: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(dst, src, xfr_bytes); data/haveged-1.9.13/src/havegetest.h:192: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 totText[8]; /* tot test text rep */ data/haveged-1.9.13/src/havegetest.h:193: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 prodText[8]; /* production test text rep */ data/haveged-1.9.13/src/havegetune.c:428: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(&anchor->cpus[i], inst, sizeof(CPU_INST)); data/haveged-1.9.13/src/havegetune.c:661: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 path[FILENAME_MAX]; data/haveged-1.9.13/src/havegetune.c:702:7: [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 term[32]; data/haveged-1.9.13/src/havegetune.c:705: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). cpu = atoi(input+3); data/haveged-1.9.13/src/havegetune.c:722:7: [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 key[32], value[32]; data/haveged-1.9.13/src/havegetune.c:726:43: [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). cfg_bitSet(&anchor->pCpuInfo, atoi(value)); data/haveged-1.9.13/src/havegetune.c:765:21: [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 (NULL != (f = fopen(path, "rb"))) { data/haveged-1.9.13/src/havegetune.c:766:7: [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[VFS_LINESIZE]; data/haveged-1.9.13/src/havegetune.c:784:7: [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 path[FILENAME_MAX]; data/haveged-1.9.13/src/havegetune.c:787: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). idx = atoi(input+5); data/haveged-1.9.13/src/havegetune.c:795:10: [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. strcpy(path+plen, "type"); data/haveged-1.9.13/src/havegetune.c:797:10: [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. strcpy(path+plen, "size"); data/haveged-1.9.13/src/havegetune.c:824:11: [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). return atoi(input); data/haveged-1.9.13/src/havegetune.c:836:7: [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 key[32], value[VFS_LINESIZE-32]; data/haveged-1.9.13/src/havegetune.h:72: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 vendor[16]; data/haveged-1.9.13/src/havegetune.h:99: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 buildOpts[SZ_BUILDREP]; /* build options */ data/haveged-1.9.13/src/havegetune.h: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 cpuOpts[SZ_CPUREP]; /* cpu options */ data/haveged-1.9.13/src/havegetune.h:101: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 icacheOpts[SZ_CACHEREP]; /* icache options */ data/haveged-1.9.13/src/havegetune.h:102: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 dcacheOpts[SZ_CACHEREP]; /* dcache options */ data/haveged-1.9.13/contrib/diags/data_prep.c:99:39: [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. if (long_options[i].has_arg!=0) strcat(short_options,":"); data/haveged-1.9.13/contrib/diags/data_prep.c:123: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). n = strlen(optarg); data/haveged-1.9.13/ent/entest.c:85: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). offs=strlen(failures); data/haveged-1.9.13/ent/entest.c:90: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). offs=strlen(failures); data/haveged-1.9.13/ent/entest.c:94: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). offs=strlen(failures); data/haveged-1.9.13/ent/entest.c:99: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). offs=strlen(failures); data/haveged-1.9.13/ent/entest.c:103: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). offs=strlen(failures); data/haveged-1.9.13/ent/entest.c:212: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). if (!strlen(filename)) { data/haveged-1.9.13/ent/entest.c:229:17: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((oc = fgetc(fp)) != EOF) { data/haveged-1.9.13/nist/nist.c:37:3: [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(basedirname, "/"); data/haveged-1.9.13/src/havege.c:347: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). if (strlen(status.tot_tests)>0) { data/haveged-1.9.13/src/havege.c:354: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). if (strlen(status.prod_tests)>0) { data/haveged-1.9.13/src/havegecmd.c:120:88: [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). ret = bind(fd, (struct sockaddr *)&su, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(su.sun_path+1)); data/haveged-1.9.13/src/havegecmd.c:169:91: [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). ret = connect(fd, (struct sockaddr *)&su, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(su.sun_path+1)); data/haveged-1.9.13/src/havegecmd.c:204:37: [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 (strncmp(cmd->cmd, arg, strlen(cmd->cmd)) == 0) { data/haveged-1.9.13/src/havegecmd.c:273: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). len = (int)strlen(enqry)+1; data/haveged-1.9.13/src/havegecmd.c:282: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). len = (int)strlen(enqry)+1; data/haveged-1.9.13/src/havegecmd.c:291: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). len = (int)strlen(enqry)+1; data/haveged-1.9.13/src/haveged.c:219:4: [1] (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 character. strcpy(short_options,""); data/haveged-1.9.13/src/haveged.c:261:39: [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. if (long_options[i].has_arg!=0) strcat(short_options,":"); data/haveged-1.9.13/src/haveged.c:359: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). len = (int)strlen(root); data/haveged-1.9.13/src/haveged.c:360:84: [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). ret = snprintf(message, sizeof(message), "%c\002%c%s%n", cmd[0], (int)(strlen(root) + 1), root, &len); data/haveged-1.9.13/src/haveged.c:760: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). if (f < 0 || strlen(suffix)>1) data/haveged-1.9.13/src/havegetune.c:701: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). if (strlen(input)> 3) { data/haveged-1.9.13/src/havegetune.c:724:14: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (1==sscanf(input, "%31s", key) && 1==sscanf(s, "%31s", value)) { data/haveged-1.9.13/src/havegetune.c:724:47: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (1==sscanf(input, "%31s", key) && 1==sscanf(s, "%31s", value)) { data/haveged-1.9.13/src/havegetune.c:783: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). if (strlen(input)> 5) { data/haveged-1.9.13/src/havegetune.c:839:14: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (1==sscanf(input, "%31s", key) && 1==sscanf(s, "%223s", value)) { data/haveged-1.9.13/src/havegetune.c:839:47: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (1==sscanf(input, "%31s", key) && 1==sscanf(s, "%223s", value)) { ANALYSIS SUMMARY: Hits = 118 Lines analyzed = 12665 in approximately 0.37 seconds (33888 lines/second) Physical Source Lines of Code (SLOC) = 9509 Hits@level = [0] 255 [1] 29 [2] 74 [3] 4 [4] 11 [5] 0 Hits@level+ = [0+] 373 [1+] 118 [2+] 89 [3+] 15 [4+] 11 [5+] 0 Hits/KSLOC@level+ = [0+] 39.226 [1+] 12.4093 [2+] 9.35955 [3+] 1.57745 [4+] 1.1568 [5+] 0 Dot directories skipped = 2 (--followdotdir overrides) 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.