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/mgdiff-1.0/externs.h Examining data/mgdiff-1.0/files.c Examining data/mgdiff-1.0/legend.c Examining data/mgdiff-1.0/manual.c Examining data/mgdiff-1.0/mgdiff.c Examining data/mgdiff-1.0/mgdiff.h Examining data/mgdiff-1.0/misc.c Examining data/mgdiff-1.0/modal.c Examining data/mgdiff-1.0/patchlevel.h Examining data/mgdiff-1.0/rundiff.c Examining data/mgdiff-1.0/spawn.c FINAL RESULTS: data/mgdiff-1.0/files.c:111:9: [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 (filename, R_OK) != 0) { data/mgdiff-1.0/files.c:536:9: [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 (filename, W_OK) == 0) { /* file exists and can be written */ data/mgdiff-1.0/files.c:696:9: [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 (filename, W_OK) == 0) { data/mgdiff-1.0/manual.c:65:14: [4] (shell) popen: 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. if ((f = popen (command, "r")) == NULL) data/mgdiff-1.0/spawn.c:112:6: [4] (shell) execvp: 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. if (execvp (prog, argv) == -1) { data/mgdiff-1.0/misc.c:73:5: [3] (random) srandom: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srandom (getpid () + getppid () + time (NULL)) ; data/mgdiff-1.0/misc.c:76:48: [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. snprintf (name, name_len, "/tmp/mgdiff-%#lx", random()) ; data/mgdiff-1.0/files.c:88: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 buffer[1024]; data/mgdiff-1.0/files.c:90:10: [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 (filename, O_RDONLY); data/mgdiff-1.0/files.c:145: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 buffer[4096]; data/mgdiff-1.0/files.c:537: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[1024]; data/mgdiff-1.0/files.c:615:17: [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 ((file = fopen (filename, "w")) == NULL) data/mgdiff-1.0/files.c:698: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[1024]; data/mgdiff-1.0/manual.c:63: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 buffer[BUFSIZ]; data/mgdiff-1.0/manual.c:74: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. (void) memcpy ((void *) &retval[size], (void *) buffer, bytes); data/mgdiff-1.0/manual.c:135: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 buffer[1024]; data/mgdiff-1.0/manual.c:142: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 buffer[1024]; data/mgdiff-1.0/manual.c:149: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 buffer[1024]; data/mgdiff-1.0/mgdiff.c:188: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 tempfname [512] = "" ; data/mgdiff-1.0/mgdiff.c:1018: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 etext[BUFSIZ]; data/mgdiff-1.0/mgdiff.c:1689: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 buffer[16]; data/mgdiff-1.0/mgdiff.c:2038: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 buffer[512]; data/mgdiff-1.0/mgdiff.c:2390:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(result,line,j); data/mgdiff-1.0/mgdiff.c:2598: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 buffer[1024]; data/mgdiff-1.0/mgdiff.c:2605: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[1024]; data/mgdiff-1.0/misc.c:77:12: [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 (name, O_CREAT | O_EXCL | O_RDWR, 0600)) < 0) { data/mgdiff-1.0/misc.c:92: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[BUFSIZ]; data/mgdiff-1.0/rundiff.c:210: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 buffer[BUFSIZ+1]; data/mgdiff-1.0/rundiff.c:219: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). file1 = fopen (path1, "r"); data/mgdiff-1.0/rundiff.c:220: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). file2 = fopen (path2, "r"); data/mgdiff-1.0/rundiff.c:245: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 cmdline[4096]; data/mgdiff-1.0/rundiff.c:672: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 buffer[BUFSIZ+1]; data/mgdiff-1.0/spawn.c:53: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 buffer[1024]; data/mgdiff-1.0/files.c:91:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). bytes = read (fd, (void *) buffer, 1024); data/mgdiff-1.0/files.c:379: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). left_label, strlen (left_label) + 1, data/mgdiff-1.0/files.c:383:19: [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). right_label, strlen (right_label) + 1, data/mgdiff-1.0/files.c:450: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). left_label, strlen (left_label) + 1, data/mgdiff-1.0/files.c:504:19: [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). right_label, strlen (right_label) + 1, data/mgdiff-1.0/manual.c:148: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). else if (strlen (value) < (unsigned int) 80) { /* command produced insufficient output */ data/mgdiff-1.0/mgdiff.c:332:51: [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). font_widestline = XTextWidth (xfs, di->longline, strlen (di->longline)); data/mgdiff-1.0/mgdiff.c:1006: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). if (strlen (tempfname) > 0) data/mgdiff-1.0/mgdiff.c:2060:61: [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). XtVaTypedArg, XmNmessageString, XmRString, buffer, strlen (buffer)+1, data/mgdiff-1.0/mgdiff.c:2258: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). str_snamel, strlen (str_snamel) + 1, NULL); data/mgdiff-1.0/mgdiff.c:2260: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). str_snamer, strlen (str_snamer) + 1, NULL); data/mgdiff-1.0/mgdiff.c:2366: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). *length += (strlen(chunk->wtext[i])+1); data/mgdiff-1.0/mgdiff.c:2368: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). *length += (strlen(chunk->text[i])+1); data/mgdiff-1.0/mgdiff.c:2389: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). j =strlen(line); data/mgdiff-1.0/modal.c:83:59: [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). XtVaTypedArg, XmNmessageString, XmRString, question, strlen (question)+1, data/mgdiff-1.0/modal.c:84:54: [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). XtVaTypedArg, XmNdialogTitle, XmRString, title, strlen (title)+1, data/mgdiff-1.0/rundiff.c:175:19: [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). di->maxcols = strlen (di->longline); data/mgdiff-1.0/rundiff.c:189:28: [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). b->arr[LEFT].tlen[0] = strlen (b->arr[LEFT].text[0]); data/mgdiff-1.0/rundiff.c:275:30: [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). b->arr[LEFT].tlen[i] = strlen (b->arr[LEFT].text[i]); data/mgdiff-1.0/rundiff.c:304:27: [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). b->arr[RIGHT].tlen[i] = strlen (b->arr[RIGHT].text[i]); data/mgdiff-1.0/rundiff.c:335:30: [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). b->arr[LEFT].tlen[i] = strlen (b->arr[LEFT].text[i]); data/mgdiff-1.0/rundiff.c:362:26: [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). b->arr[LEFT].tlen[i] = strlen (b->arr[LEFT].text[i]); data/mgdiff-1.0/rundiff.c:375:27: [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). b->arr[RIGHT].tlen[i] = strlen (b->arr[RIGHT].text[i]); data/mgdiff-1.0/rundiff.c:403:30: [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). b->arr[LEFT].tlen[i] = strlen (b->arr[LEFT].text[i]); data/mgdiff-1.0/rundiff.c:432:26: [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). b->arr[LEFT].tlen[i] = strlen (b->arr[LEFT].text[i]); data/mgdiff-1.0/rundiff.c:495: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). b->arr[LEFT].tlen[i] = strlen (b->arr[LEFT].text[i]); data/mgdiff-1.0/rundiff.c:651:6: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = getc (f); data/mgdiff-1.0/rundiff.c:677:14: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). buffer[j] = getc (f); data/mgdiff-1.0/rundiff.c:689:9: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (getc (f) != '\n') ANALYSIS SUMMARY: Hits = 62 Lines analyzed = 5157 in approximately 0.15 seconds (35469 lines/second) Physical Source Lines of Code (SLOC) = 3768 Hits@level = [0] 47 [1] 29 [2] 26 [3] 2 [4] 5 [5] 0 Hits@level+ = [0+] 109 [1+] 62 [2+] 33 [3+] 7 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 28.9278 [1+] 16.4544 [2+] 8.75796 [3+] 1.85775 [4+] 1.32696 [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.