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/e2tools-0.0.16/e2tools.c
Examining data/e2tools-0.0.16/e2tools.h
Examining data/e2tools-0.0.16/elist.c
Examining data/e2tools-0.0.16/elist.h
Examining data/e2tools-0.0.16/ln.c
Examining data/e2tools-0.0.16/mv.c
Examining data/e2tools-0.0.16/progress.c
Examining data/e2tools-0.0.16/read.c
Examining data/e2tools-0.0.16/tail.c
Examining data/e2tools-0.0.16/util.c
Examining data/e2tools-0.0.16/write.c
Examining data/e2tools-0.0.16/ls.c
Examining data/e2tools-0.0.16/copy.c
Examining data/e2tools-0.0.16/mkdir.c
Examining data/e2tools-0.0.16/rm.c

FINAL RESULTS:

data/e2tools-0.0.16/read.c:342:9:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
    i = chmod(name, ext2_mode_xlate(inode->i_mode));
data/e2tools-0.0.16/read.c:347:7:  [5] (race) chown:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchown( ) instead.
  i = chown(name, inode->i_uid, inode->i_gid);
data/e2tools-0.0.16/read.c:352:9:  [5] (race) chown:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchown( ) instead.
    i = chown(name, inode->i_uid, inode->i_gid);
data/e2tools-0.0.16/ls.c:650:7:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
      sprintf(datestr, "%2d-%s-%4d %02d:%02d",
data/e2tools-0.0.16/ls.c:735:9:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
        sprintf(tmp, "%7d %s%c", info->inode_num, info->name, rbr);
data/e2tools-0.0.16/ls.c:737:9:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
        sprintf(tmp, "%s%c", info->name, rbr);
data/e2tools-0.0.16/ls.c:742:9:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
        sprintf(tmp, "%7d %c%s%c", info->inode_num, lbr, info->name, rbr);
data/e2tools-0.0.16/ls.c:744:9:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
        sprintf(tmp, "%c%s%c", lbr, info->name, rbr);
data/e2tools-0.0.16/rm.c:215:17:  [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(gbl_dir_name, dir_name);
data/e2tools-0.0.16/rm.c:242:19:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
                  sprintf(gbl_dir_name, "%s/%s", (dir_name == NULL)?".":
data/e2tools-0.0.16/copy.c:276:15:  [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, "0ad:G:O:pP:s:v")) != EOF)
data/e2tools-0.0.16/ln.c:116:15:  [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, "vfs")) != EOF)
data/e2tools-0.0.16/ls.c:349:15:  [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, "acDd:filrt")) != EOF)
data/e2tools-0.0.16/mkdir.c:130:15:  [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, "G:O:P:v")) != EOF)
data/e2tools-0.0.16/mv.c:107:15:  [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, "vfs")) != EOF)
data/e2tools-0.0.16/rm.c:130:15:  [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, "vr")) != EOF)
data/e2tools-0.0.16/tail.c:129:15:  [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, "vFfn:s:")) != EOF)
data/e2tools-0.0.16/copy.c:107: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 cur_out_dir[BUF_SIZE];
data/e2tools-0.0.16/copy.c:244: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 tmpbuf[BUF_SIZE];
data/e2tools-0.0.16/copy.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 outpath[BUF_SIZE];
data/e2tools-0.0.16/copy.c:290: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).
          def_stat.st_gid = atoi(optarg);
data/e2tools-0.0.16/copy.c:294: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).
          def_stat.st_uid = atoi(optarg);
data/e2tools-0.0.16/copy.c:973: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.
  static char tmpstr[BUF_SIZE];
data/e2tools-0.0.16/copy.c:989: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.
  static char last_cwd[BUF_SIZE];
data/e2tools-0.0.16/ls.c:149: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			name[EXT2_NAME_LEN];
data/e2tools-0.0.16/ls.c:626: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 datestr[80];
data/e2tools-0.0.16/ls.c:656:5:  [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(datestr, "                 ");
data/e2tools-0.0.16/ls.c:706: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 tmp[300];
data/e2tools-0.0.16/mkdir.c:138: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).
          def_stat.st_gid = atoi(optarg);
data/e2tools-0.0.16/mkdir.c:141: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).
          def_stat.st_uid = atoi(optarg);
data/e2tools-0.0.16/progress.c:39: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 prog_file[PROG_FILE_SIZE+1];
data/e2tools-0.0.16/progress.c:99:7:  [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(prog_file, file, len);
data/e2tools-0.0.16/read.c:124:26:  [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).
  else if (-1 == (dest = open(outfile, O_CREAT | O_WRONLY | O_TRUNC, 0666)))
data/e2tools-0.0.16/read.c:291: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[4096];
data/e2tools-0.0.16/rm.c:44: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 gbl_dir_name[8192];
data/e2tools-0.0.16/rm.c:297: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 name[EXT2_NAME_LEN];
data/e2tools-0.0.16/rm.c:362: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 name[EXT2_NAME_LEN];
data/e2tools-0.0.16/tail.c:143:23:  [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).
          num_lines = atoi(optarg);
data/e2tools-0.0.16/tail.c:146:23:  [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).
          sleep_int = atoi(optarg);
data/e2tools-0.0.16/tail.c:250: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[BLK_SIZE];
data/e2tools-0.0.16/write.c:145:21:  [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 (0 > (fd = open(infile, O_RDONLY)))
data/e2tools-0.0.16/write.c:330: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[8192];
data/e2tools-0.0.16/copy.c:365: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).
      tmp_val = strlen(src_dir) - 1;
data/e2tools-0.0.16/copy.c:387: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).
      max_out_len = strlen(outpath);
data/e2tools-0.0.16/copy.c:432: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).
          max_out_len = strlen(outpath);
data/e2tools-0.0.16/copy.c:482:11:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
          strncpy(cur_out_dir, (dest_dir) ? dest_dir : ".", BUF_SIZE);
data/e2tools-0.0.16/copy.c:596:19:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
                  strncpy(out_file, ptr, max_out_len);
data/e2tools-0.0.16/copy.c:740:15:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
              strncpy(outfile, (ptr != NULL) ? ++ptr : dptr, BUF_SIZE);
data/e2tools-0.0.16/copy.c:760:11:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
          strncpy(outfile, dptr, BUF_SIZE);
data/e2tools-0.0.16/copy.c:800:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(cur_out_dir, (dest_dir) ? dest_dir : ".", BUF_SIZE);
data/e2tools-0.0.16/copy.c:839:19:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
                  strncpy(out_file, ptr, max_file_len);
data/e2tools-0.0.16/copy.c:1007:7:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
      strncpy(last_cwd, newdir, BUF_SIZE);
data/e2tools-0.0.16/copy.c:1011:11:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
          strncpy(cur_out_dir, newdir, BUF_SIZE);
data/e2tools-0.0.16/copy.c:1036: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).
  ptr = inbuf + strlen(inbuf);
data/e2tools-0.0.16/copy.c:1048:10:  [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).
  return(strlen(inbuf));
data/e2tools-0.0.16/copy.c:1062:15:  [1] (buffer) getchar:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  while ((c = getchar()) != EOF && c != '\0')
data/e2tools-0.0.16/copy.c:1081:10:  [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).
  return(strlen(inbuf));
data/e2tools-0.0.16/ls.c:155:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(name, dirent->name, thislen);
data/e2tools-0.0.16/ls.c:506:35:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
        if(add_ls_file(base_name, strlen(base_name), cwd, inode, 0,
data/e2tools-0.0.16/ls.c:747:13:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
  thislen = strlen(tmp);
data/e2tools-0.0.16/progress.c:92:13:  [1] (buffer) strlen:
  Does not handle strings that are not \0-terminated; if given one it may
  perform an over-read (it could cause a crash if unprotected) (CWE-126).
      len = strlen(file);
data/e2tools-0.0.16/rm.c:216:47:  [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).
                gbl_path_end = gbl_dir_name + strlen(gbl_dir_name);
data/e2tools-0.0.16/rm.c:244:49:  [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).
                  gbl_path_end = gbl_dir_name + strlen(gbl_dir_name);
data/e2tools-0.0.16/rm.c:307:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(name, dirent->name, thislen);
data/e2tools-0.0.16/rm.c:326:7:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
      strncpy(gbl_path_end, dirent->name, dirent->name_len);
data/e2tools-0.0.16/rm.c:373:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(name, dirent->name, thislen);
data/e2tools-0.0.16/util.c:282: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).
  if (NULL == (tmpstr = alloca((strlen(shell)) << 1 + 3)))
data/e2tools-0.0.16/write.c:163:7:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
      umask(cur_umask = umask(0)); /* get the current umask */
data/e2tools-0.0.16/write.c:163:25:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
      umask(cur_umask = umask(0)); /* get the current umask */
data/e2tools-0.0.16/write.c:342:28:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  while (0 < (bytes_read = read(fd, buf, sizeof(buf))))

ANALYSIS SUMMARY:

Hits = 70
Lines analyzed = 6359 in approximately 0.16 seconds (39205 lines/second)
Physical Source Lines of Code (SLOC) = 3693
Hits@level = [0] 142 [1]  28 [2]  25 [3]   7 [4]   7 [5]   3
Hits@level+ = [0+] 212 [1+]  70 [2+]  42 [3+]  17 [4+]  10 [5+]   3
Hits/KSLOC@level+ = [0+] 57.4059 [1+] 18.9548 [2+] 11.3729 [3+] 4.6033 [4+] 2.70783 [5+] 0.812348
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.