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/magicrescue-1.1.10/src/array.c
Examining data/magicrescue-1.1.10/src/array.h
Examining data/magicrescue-1.1.10/src/dupemap.c
Examining data/magicrescue-1.1.10/src/extract.c
Examining data/magicrescue-1.1.10/src/find_dbm.h
Examining data/magicrescue-1.1.10/src/largefile.h
Examining data/magicrescue-1.1.10/src/magicrescue.c
Examining data/magicrescue-1.1.10/src/magicrescue.h
Examining data/magicrescue-1.1.10/src/recipe.c
Examining data/magicrescue-1.1.10/src/recipe.h
Examining data/magicrescue-1.1.10/src/recur.c
Examining data/magicrescue-1.1.10/src/recur.h
Examining data/magicrescue-1.1.10/src/scanner.c
Examining data/magicrescue-1.1.10/src/scanner.h
Examining data/magicrescue-1.1.10/src/util.c
Examining data/magicrescue-1.1.10/src/util.h
Examining data/magicrescue-1.1.10/tools/inputseek.c
Examining data/magicrescue-1.1.10/tools/safecat.c
Examining data/magicrescue-1.1.10/tools/textextract.c

FINAL RESULTS:

data/magicrescue-1.1.10/src/extract.c:89:2:  [4] (shell) execl:
  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.
	execl("/bin/sh", "/bin/sh", "-c", command, "sh", argument, NULL);
data/magicrescue-1.1.10/src/extract.c:141:6:  [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(origname, newname);
data/magicrescue-1.1.10/src/magicrescue.c:555:5:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
    sprintf(buf, "PATH=%s%s%s:%s", "tools",
data/magicrescue-1.1.10/src/recur.c:102: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(stack->prefix, path);
data/magicrescue-1.1.10/src/recur.c:147:2:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
	strcpy(stack->prefix, fullname);
data/magicrescue-1.1.10/src/recur.c:195:3:  [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(name, cur);
data/magicrescue-1.1.10/tools/inputseek.c:32:5:  [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.
    execvp(argv[2], &argv[2]);
data/magicrescue-1.1.10/src/dupemap.c:62:21:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
    char *env_tmp = getenv("TMP");
data/magicrescue-1.1.10/src/dupemap.c:362:17:  [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, "d:m:I:M:")) >= 0) {
data/magicrescue-1.1.10/src/magicrescue.c:561:2:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
	getenv("PATH"));
data/magicrescue-1.1.10/src/magicrescue.c:564:17:  [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, "b:d:r:I:M:O:")) >= 0) {
data/magicrescue-1.1.10/tools/safecat.c:59:17:  [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, "d:u:t:")) >= 0) {
data/magicrescue-1.1.10/tools/textextract.c:320:17:  [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, "M:s:b:l:r:")) >= 0) {
data/magicrescue-1.1.10/src/array.c:51: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(&tmp[(array->elements-1) * array->el_len], el, array->el_len);
data/magicrescue-1.1.10/src/dupemap.c:78: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 file[PATH_MAX];
data/magicrescue-1.1.10/src/dupemap.c:201:12:  [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[BUFLEN];
data/magicrescue-1.1.10/src/dupemap.c:210:10:  [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).
    fp = fopen (file, "rb");
data/magicrescue-1.1.10/src/dupemap.c:357: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 name[PATH_MAX], *dbname = NULL;
data/magicrescue-1.1.10/src/dupemap.c:374:24:  [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).
	    min_size = (off_t)atol(optarg);
data/magicrescue-1.1.10/src/dupemap.c:383:24:  [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).
	    max_size = (off_t)atol(optarg);
data/magicrescue-1.1.10/src/dupemap.c:441:3:  [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).
		fopen(file_names_from, "r");
data/magicrescue-1.1.10/src/extract.c:107: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 mvbuf[2*PATH_MAX]; /* it has to be semi-large */
data/magicrescue-1.1.10/src/extract.c:134: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 newname[PATH_MAX];
data/magicrescue-1.1.10/src/extract.c:149: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 outfile[PATH_MAX];
data/magicrescue-1.1.10/src/magicrescue.c:234: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).
	    (fd = open(device, O_RDONLY)) == -1) {
data/magicrescue-1.1.10/src/magicrescue.c:287: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(scanbuf, readbuf + got - overlap, overlap);
data/magicrescue-1.1.10/src/magicrescue.c:338:10:  [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(recipefile, "r");
data/magicrescue-1.1.10/src/magicrescue.c:340: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 path[PATH_MAX];
data/magicrescue-1.1.10/src/magicrescue.c:342:7:  [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(path, "r");
data/magicrescue-1.1.10/src/magicrescue.c:358: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 opname[64];
data/magicrescue-1.1.10/src/magicrescue.c:410: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_val[16], buf_mask[16];
data/magicrescue-1.1.10/src/magicrescue.c:567:22:  [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).
	    long boundary = atol(optarg);
data/magicrescue-1.1.10/src/magicrescue.c:599: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 fullname[PATH_MAX];
data/magicrescue-1.1.10/src/magicrescue.c:654: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 inputfile[PATH_MAX];
data/magicrescue-1.1.10/src/magicrescue.c:656:3:  [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).
		fopen(file_names_from, "r");
data/magicrescue-1.1.10/src/magicrescue.h:11: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 device[PATH_MAX];
data/magicrescue-1.1.10/src/magicrescue.h:12: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 device_basename[PATH_MAX];
data/magicrescue-1.1.10/src/recipe.h:24: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 extension[64];
data/magicrescue-1.1.10/src/recur.c:41: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 prefix[PATH_MAX];
data/magicrescue-1.1.10/src/recur.c:54: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 fullname[PATH_MAX];
data/magicrescue-1.1.10/src/util.c:56:16:  [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).
	long result = atol(str);
data/magicrescue-1.1.10/tools/textextract.c:326: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).
	    max_score = atoi(optarg);
data/magicrescue-1.1.10/tools/textextract.c:329:20:  [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).
	    block_score = atoi(optarg);
data/magicrescue-1.1.10/tools/textextract.c:332:17:  [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).
	    max_line = atoi(optarg);
data/magicrescue-1.1.10/tools/textextract.c:335:20:  [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).
	    max_reverse = atoi(optarg);
data/magicrescue-1.1.10/tools/textextract.c:357:3:  [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).
		open(argv[optind], O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) {
data/magicrescue-1.1.10/src/dupemap.c:451: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).
	    name[strlen(name)-1] = '\0'; /* kill newline */
data/magicrescue-1.1.10/src/extract.c:114:19:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while ((got = read(outfd, mvbuf + has, sizeof(mvbuf)-has - 1)) > 0) {
data/magicrescue-1.1.10/src/extract.c:133:6:  [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(rename_pos) < 128) {
data/magicrescue-1.1.10/src/magicrescue.c:270:19:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while ((got = read(fd, readbuf, readsize)) > overlap) {
data/magicrescue-1.1.10/src/magicrescue.c:360:6:  [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).
	buf[strlen(buf) - 1] = '\0'; /* kill trailing newline */
data/magicrescue-1.1.10/src/magicrescue.c:362:6:  [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 (sscanf(buf, "%d %63s %n",
data/magicrescue-1.1.10/src/magicrescue.c:412:11:  [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 (sscanf(param, "%15s %15s", buf_val, buf_mask) != 2) {
data/magicrescue-1.1.10/src/magicrescue.c:452:10:  [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 (sscanf(buf, "extension %63s", r.extension) == 1) {
data/magicrescue-1.1.10/src/magicrescue.c:665:16:  [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).
	    inputfile[strlen(inputfile)-1] = '\0'; /* kill newline */
data/magicrescue-1.1.10/src/recur.c:82: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).
    for (p = &s[strlen(s) - 1]; p >= s; p--) {
data/magicrescue-1.1.10/src/recur.c:104: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).
	char *s = &stack->prefix[strlen(stack->prefix)-1];
data/magicrescue-1.1.10/src/recur.c:160:46:  [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 (paths == NULL || paths[0] == NULL || strlen(paths[0]) >= PATH_MAX)
data/magicrescue-1.1.10/src/util.c:45: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).
    size_t i, len = strlen(str);
data/magicrescue-1.1.10/src/util.c:58: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).
	switch (str[strlen(str)-1]) {
data/magicrescue-1.1.10/src/util.c:114: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).
    const size_t slen = strlen(src);
data/magicrescue-1.1.10/tools/safecat.c:90:19:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	    read_count = read(0, buf, bufsize);
data/magicrescue-1.1.10/tools/textextract.c:236:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	    || read(0, buf, read_count) != read_count) {
data/magicrescue-1.1.10/tools/textextract.c:265:26:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while ((read_count = read(0, bufpos, bufsize - (bufpos-buf)) ) > 0) {

ANALYSIS SUMMARY:

Hits = 64
Lines analyzed = 2735 in approximately 0.11 seconds (25751 lines/second)
Physical Source Lines of Code (SLOC) = 1948
Hits@level = [0]  71 [1]  18 [2]  33 [3]   6 [4]   7 [5]   0
Hits@level+ = [0+] 135 [1+]  64 [2+]  46 [3+]  13 [4+]   7 [5+]   0
Hits/KSLOC@level+ = [0+] 69.3018 [1+] 32.8542 [2+] 23.614 [3+] 6.67351 [4+] 3.59343 [5+]   0
Dot directories skipped = 1 (--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.