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/clamfs-1.2.0/src/clamfs.cxx Examining data/clamfs-1.2.0/src/stats.cxx Examining data/clamfs-1.2.0/src/clamav.cxx Examining data/clamfs-1.2.0/src/rlog.cxx Examining data/clamfs-1.2.0/src/fdpassing.h Examining data/clamfs-1.2.0/src/mnotify.cxx Examining data/clamfs-1.2.0/src/config.cxx Examining data/clamfs-1.2.0/src/scancache.cxx Examining data/clamfs-1.2.0/version.h FINAL RESULTS: data/clamfs-1.2.0/src/clamfs.cxx:194:11: [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. res = readlink(fpath, buf, size - 1); data/clamfs-1.2.0/src/clamfs.cxx:505:15: [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(fpath, mode); data/clamfs-1.2.0/src/clamfs.cxx:112:5: [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(fixed,path); data/clamfs-1.2.0/src/clamfs.cxx:175:11: [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. res = access(fpath, mask); data/clamfs-1.2.0/src/clamfs.cxx:678: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(real_path.get(), config["root"]); data/clamfs-1.2.0/src/clamfs.cxx:679:5: [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(real_path.get(), path); data/clamfs-1.2.0/src/clamav.cxx:131:14: [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 fdbuf[CMSG_SPACE(sizeof(int))]; data/clamfs-1.2.0/src/clamav.cxx:146: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(CMSG_DATA(cmsg), &fd, sizeof(fd)); data/clamfs-1.2.0/src/clamav.cxx:183:18: [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 fd = open(filename, O_RDONLY); data/clamfs-1.2.0/src/clamfs.cxx:574:33: [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 clamfs_utimens(const char *path, const struct timespec ts[2], data/clamfs-1.2.0/src/clamfs.cxx:609: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(fpath, fi->flags, mode); data/clamfs-1.2.0/src/clamfs.cxx:644: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(fpath, fi->flags); data/clamfs-1.2.0/src/clamfs.cxx:731:37: [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). if (file_stat.st_size > atoi(config["maximal-size"])) { /* file too big */ data/clamfs-1.2.0/src/clamfs.cxx:1286:21: [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. fuse_argv = new char *[FUSE_MAX_ARGS]; data/clamfs-1.2.0/src/clamfs.cxx:1332:14: [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). savefd = open(".", 0); data/clamfs-1.2.0/src/clamfs.cxx:1355:10: [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). (atol(config["entries"]) <= 0)) { data/clamfs-1.2.0/src/clamfs.cxx:1360:10: [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). (atol(config["expire"]) <= 0)) { data/clamfs-1.2.0/src/clamfs.cxx:1368:31: [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). cache = new ScanCache(atol(config["entries"]), atol(config["expire"])); data/clamfs-1.2.0/src/clamfs.cxx:1368:56: [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). cache = new ScanCache(atol(config["entries"]), atol(config["expire"])); data/clamfs-1.2.0/src/clamfs.cxx:1377:10: [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). (atol(config["every"]) != 0)) { data/clamfs-1.2.0/src/clamfs.cxx:1379:27: [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). stats = new Stats(atol(config["every"])); data/clamfs-1.2.0/src/rlog.cxx:96:15: [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). fileLog = open(filename, O_WRONLY | O_CREAT | O_APPEND, mode); data/clamfs-1.2.0/src/clamfs.cxx:96: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). char* fixed = new char[strlen(path)+2]; data/clamfs-1.2.0/src/clamfs.cxx:111:5: [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(fixed,"."); data/clamfs-1.2.0/src/clamfs.cxx:677:43: [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). shared_array<char> real_path(new char[strlen(config["root"])+strlen(path)+1]); data/clamfs-1.2.0/src/clamfs.cxx:677:66: [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). shared_array<char> real_path(new char[strlen(config["root"])+strlen(path)+1]); data/clamfs-1.2.0/src/clamfs.cxx:1225:5: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(0); data/clamfs-1.2.0/src/clamfs.cxx:1242: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). ((strncmp(argv[1], "-h", strlen("-h")) == 0) || data/clamfs-1.2.0/src/clamfs.cxx:1243:39: [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). (strncmp(argv[1], "--help", strlen("--help")) == 0)))) { ANALYSIS SUMMARY: Hits = 29 Lines analyzed = 2288 in approximately 0.08 seconds (26924 lines/second) Physical Source Lines of Code (SLOC) = 1391 Hits@level = [0] 0 [1] 7 [2] 16 [3] 0 [4] 4 [5] 2 Hits@level+ = [0+] 29 [1+] 29 [2+] 22 [3+] 6 [4+] 6 [5+] 2 Hits/KSLOC@level+ = [0+] 20.8483 [1+] 20.8483 [2+] 15.816 [3+] 4.31344 [4+] 4.31344 [5+] 1.43781 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.