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/cachefilesd-0.10.10/cachefilesd.c FINAL RESULTS: data/cachefilesd-0.10.10/cachefilesd.c:156:40: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. static __attribute__((noreturn, format(printf, 2, 3))) data/cachefilesd-0.10.10/cachefilesd.c:163:3: [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. vfprintf(stderr, fmt, va); data/cachefilesd-0.10.10/cachefilesd.c:187:30: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. static __attribute__((format(printf, 3, 4))) data/cachefilesd-0.10.10/cachefilesd.c:195:4: [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. vfprintf(stderr, fmt, va); data/cachefilesd-0.10.10/cachefilesd.c:949:6: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. n = sprintf(buffer, "inuse %s", filename); data/cachefilesd-0.10.10/cachefilesd.c:969:6: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. n = sprintf(buffer, "cull %s", filename); data/cachefilesd-0.10.10/cachefilesd.c:303: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 (opt = getopt(argc, argv, "dsnNf:p:v"), data/cachefilesd-0.10.10/cachefilesd.c:76: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 name[1]; /* name of this object */ data/cachefilesd-0.10.10/cachefilesd.c:270: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). pf = fopen(pidfile, "w"); data/cachefilesd-0.10.10/cachefilesd.c:369: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). _cachefd = open(devfile, O_RDWR); data/cachefilesd-0.10.10/cachefilesd.c:374: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). _cachefd = open(procfile, O_RDWR); data/cachefilesd-0.10.10/cachefilesd.c:390:11: [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). nullfd = open("/dev/null", O_RDWR); data/cachefilesd-0.10.10/cachefilesd.c:395:11: [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). config = fopen(configfile, "r"); data/cachefilesd-0.10.10/cachefilesd.c:601: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[PATH_MAX + 1]; data/cachefilesd-0.10.10/cachefilesd.c:615:16: [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). graveyardfd = open(graveyardpath, O_DIRECTORY); data/cachefilesd-0.10.10/cachefilesd.c:816: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 name[NAME_MAX + 1]; data/cachefilesd-0.10.10/cachefilesd.c:865:4: [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(name, de->d_name, len); data/cachefilesd-0.10.10/cachefilesd.c:891: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[4096 + 1], *tok, *next, *arg; data/cachefilesd-0.10.10/cachefilesd.c:946: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[NAME_MAX + 30]; data/cachefilesd-0.10.10/cachefilesd.c:966: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[NAME_MAX + 30]; data/cachefilesd-0.10.10/cachefilesd.c:1018: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(object->name, name, len + 1); data/cachefilesd-0.10.10/cachefilesd.c:1110: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 namebuf[40]; data/cachefilesd-0.10.10/cachefilesd.c:1123:3: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(namebuf, "x%lxx%xx", tv.tv_sec, uniquifier++); data/cachefilesd-0.10.10/cachefilesd.c:1533: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(cullready, cullbuild, n); data/cachefilesd-0.10.10/cachefilesd.c:498: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). if (strlen(sp) > PATH_MAX - 10) data/cachefilesd-0.10.10/cachefilesd.c:515: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). if (write(cachefd, line, strlen(line)) < 0) { data/cachefilesd-0.10.10/cachefilesd.c:859: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). len = strlen(de->d_name) + 1; data/cachefilesd-0.10.10/cachefilesd.c:894:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). n = read(cachefd, buffer, sizeof(buffer) - 1); data/cachefilesd-0.10.10/cachefilesd.c:1007: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). len = strlen(name); ANALYSIS SUMMARY: Hits = 29 Lines analyzed = 1650 in approximately 0.08 seconds (20877 lines/second) Physical Source Lines of Code (SLOC) = 1121 Hits@level = [0] 5 [1] 5 [2] 17 [3] 1 [4] 6 [5] 0 Hits@level+ = [0+] 34 [1+] 29 [2+] 24 [3+] 7 [4+] 6 [5+] 0 Hits/KSLOC@level+ = [0+] 30.3301 [1+] 25.8698 [2+] 21.4095 [3+] 6.24442 [4+] 5.35236 [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.