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/mhddfs-0.1.39+nmu1/tests/plocks.c Examining data/mhddfs-0.1.39+nmu1/tests/rename.c Examining data/mhddfs-0.1.39+nmu1/src/flist.c Examining data/mhddfs-0.1.39+nmu1/src/debug.h Examining data/mhddfs-0.1.39+nmu1/src/debug.c Examining data/mhddfs-0.1.39+nmu1/src/tools.h Examining data/mhddfs-0.1.39+nmu1/src/usage.c Examining data/mhddfs-0.1.39+nmu1/src/flist.h Examining data/mhddfs-0.1.39+nmu1/src/usage.h Examining data/mhddfs-0.1.39+nmu1/src/tools.c Examining data/mhddfs-0.1.39+nmu1/src/test/pwrite.c Examining data/mhddfs-0.1.39+nmu1/src/test/statvfs.c Examining data/mhddfs-0.1.39+nmu1/src/parse_options.c Examining data/mhddfs-0.1.39+nmu1/src/main.c Examining data/mhddfs-0.1.39+nmu1/src/parse_options.h Examining data/mhddfs-0.1.39+nmu1/src/version.h FINAL RESULTS: data/mhddfs-0.1.39+nmu1/src/main.c:267:13: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. int res = readlink(link, buf, size); data/mhddfs-0.1.39+nmu1/src/main.c:552:4: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. chown(name, fuse_get_context()->uid, gid); data/mhddfs-0.1.39+nmu1/src/main.c:737:9: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. res = chmod(object, mode); data/mhddfs-0.1.39+nmu1/src/main.c:889:5: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. chown(nod, fcontext->uid, fcontext->gid); data/mhddfs-0.1.39+nmu1/src/tools.c:502:3: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. chown(path_parent, st.st_uid, st.st_gid); data/mhddfs-0.1.39+nmu1/src/tools.c:503:3: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod(path_parent, st.st_mode); data/mhddfs-0.1.39+nmu1/src/debug.c:43:10: [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. int res=vfprintf(mhdd.debug, fmt, ap); data/mhddfs-0.1.39+nmu1/src/main.c:501:13: [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. int res = access(file, mask); data/mhddfs-0.1.39+nmu1/src/parse_options.c:199:2: [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(info, FUSE_MP_OPT_STR); data/mhddfs-0.1.39+nmu1/src/parse_options.c:203: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(info, mhdd.dirs[i]); data/mhddfs-0.1.39+nmu1/src/tools.c:410:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(path, "%s%s", dir, file); data/mhddfs-0.1.39+nmu1/src/tools.c:414:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(path, "%s/%s", dir, file); data/mhddfs-0.1.39+nmu1/src/tools.c:549: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(dir, file); data/mhddfs-0.1.39+nmu1/src/usage.c:46:2: [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(to, usage); data/mhddfs-0.1.39+nmu1/src/debug.c:21: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 tstr[64]; data/mhddfs-0.1.39+nmu1/src/main.c:118: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(buf, stats, sizeof(struct statvfs)); data/mhddfs-0.1.39+nmu1/src/main.c:289:9: [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(path, fi->flags, mode); data/mhddfs-0.1.39+nmu1/src/main.c:291:9: [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(path, fi->flags); data/mhddfs-0.1.39+nmu1/src/main.c:314:8: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = open(path, fi->flags, mode); data/mhddfs-0.1.39+nmu1/src/main.c:316:8: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = open(path, fi->flags); data/mhddfs-0.1.39+nmu1/src/main.c:690:31: [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 int mhdd_utimens(const char *path, const struct timespec ts[2]) data/mhddfs-0.1.39+nmu1/src/main.c:877: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). res = open(nod, O_CREAT | O_EXCL | O_WRONLY, mode); data/mhddfs-0.1.39+nmu1/src/parse_options.c:78: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 cpwd[PATH_MAX]; data/mhddfs-0.1.39+nmu1/src/parse_options.c:183:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(args, &tmp, sizeof(struct fuse_args)); data/mhddfs-0.1.39+nmu1/src/parse_options.c:242:14: [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). mhdd.debug=fopen(mhdd.debug_file, "a"); data/mhddfs-0.1.39+nmu1/src/test/pwrite.c:25:13: [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). int hfile=open(argv[1], O_CREAT|O_EXCL|O_RDWR); data/mhddfs-0.1.39+nmu1/src/tools.c:149:13: [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 ((fh = open(new_name, flags)) == -1) { data/mhddfs-0.1.39+nmu1/src/tools.c:260:16: [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 (!(input = fopen(from, "r"))) data/mhddfs-0.1.39+nmu1/src/tools.c:266: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 (!(output = fopen(to, "w+"))) { data/mhddfs-0.1.39+nmu1/src/main.c:228:5: [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). strlen(new_item->name), data/mhddfs-0.1.39+nmu1/src/parse_options.c:196:38: [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 (i=l=0; i<mhdd.cdirs; i++) l += strlen(mhdd.dirs[i])+2; data/mhddfs-0.1.39+nmu1/src/parse_options.c:202:10: [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 (i) strcat(info, ";"); data/mhddfs-0.1.39+nmu1/src/parse_options.c:257: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). int len = strlen(mhdd.mlimit_str); data/mhddfs-0.1.39+nmu1/src/tools.c:403: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). int plen=strlen(dir); data/mhddfs-0.1.39+nmu1/src/tools.c:404: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). int flen=strlen(file); data/mhddfs-0.1.39+nmu1/src/tools.c:417:7: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). plen=strlen(path); data/mhddfs-0.1.39+nmu1/src/tools.c:531: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). int len=strlen(dir); data/mhddfs-0.1.39+nmu1/src/tools.c:543: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). int len=strlen(dir); ANALYSIS SUMMARY: Hits = 38 Lines analyzed = 2627 in approximately 0.08 seconds (32603 lines/second) Physical Source Lines of Code (SLOC) = 1948 Hits@level = [0] 33 [1] 9 [2] 15 [3] 0 [4] 8 [5] 6 Hits@level+ = [0+] 71 [1+] 38 [2+] 29 [3+] 14 [4+] 14 [5+] 6 Hits/KSLOC@level+ = [0+] 36.4476 [1+] 19.5072 [2+] 14.8871 [3+] 7.18686 [4+] 7.18686 [5+] 3.08008 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.