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/sxiv-26/autoreload_inotify.c Examining data/sxiv-26/autoreload_nop.c Examining data/sxiv-26/commands.c Examining data/sxiv-26/config.def.h Examining data/sxiv-26/icon/data.h Examining data/sxiv-26/image.c Examining data/sxiv-26/main.c Examining data/sxiv-26/options.c Examining data/sxiv-26/sxiv.h Examining data/sxiv-26/thumbs.c Examining data/sxiv-26/utf8.h Examining data/sxiv-26/util.c Examining data/sxiv-26/window.c FINAL RESULTS: data/sxiv-26/autoreload_inotify.c:75: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(arl->filename, base); data/sxiv-26/image.c:301:6: [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. if (access(file->path, R_OK) == 0 && data/sxiv-26/main.c:111:6: [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. if (access(filename, R_OK) < 0 || data/sxiv-26/main.c:243:3: [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(info.f.cmd, info.f.cmd, files[fileidx].name, w, h, NULL); data/sxiv-26/main.c:343:6: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. n = vsnprintf(bar->p, len, fmt, ap); data/sxiv-26/main.c:517:3: [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(keyhandler.f.cmd, keyhandler.f.cmd, kstr, NULL); data/sxiv-26/main.c:923:8: [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. if (access(cmd[i]->cmd, X_OK) != 0) data/sxiv-26/thumbs.c:136:7: [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. if (access(filename, F_OK) < 0) { data/sxiv-26/util.c:71: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, ap); data/sxiv-26/main.c:112:14: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. (path = realpath(filename, NULL)) == NULL) data/sxiv-26/main.c:911:17: [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. if ((homedir = getenv("XDG_CONFIG_HOME")) == NULL || homedir[0] == '\0') { data/sxiv-26/main.c:912:13: [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. homedir = getenv("HOME"); data/sxiv-26/options.c:75:16: [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, "A:abce:fG:g:hin:N:opqrS:s:tvZz:")) != -1) { data/sxiv-26/thumbs.c:169:17: [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. if ((homedir = getenv("XDG_CACHE_HOME")) == NULL || homedir[0] == '\0') { data/sxiv-26/thumbs.c:170:13: [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. homedir = getenv("HOME"); data/sxiv-26/autoreload_inotify.c:80: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 d[4096]; /* aligned buffer */ data/sxiv-26/image.c:495:6: [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(&data[i], &data[(r & 8) * dw], dw * sizeof(data[0])); data/sxiv-26/main.c:231: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 w[12], h[12]; data/sxiv-26/main.c:259: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 buf[BAR_L_LEN]; data/sxiv-26/main.c:479: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 kstr[32]; data/sxiv-26/thumbs.c:279:18: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). (tmpfd = mkstemp(tmppath)) >= 0) data/sxiv-26/util.c:56: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(d, s, n); data/sxiv-26/autoreload_inotify.c:91:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t len = read(arl->fd, buf.d, sizeof(buf.d)); data/sxiv-26/main.c:262:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). n = read(info.fd, buf, sizeof(buf)); data/sxiv-26/main.c:369:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(l->buf, files[fileidx].name, l->size); data/sxiv-26/main.c:388:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(l->buf, files[fileidx].name, l->size); data/sxiv-26/main.c:505:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(win.bar.l.buf, "Running key handler...", win.bar.l.size); data/sxiv-26/main.c:920: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). n = strlen(homedir) + strlen(dsuffix) + strlen(name[i]) + 12; data/sxiv-26/main.c:920:26: [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). n = strlen(homedir) + strlen(dsuffix) + strlen(name[i]) + 12; data/sxiv-26/main.c:920:44: [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). n = strlen(homedir) + strlen(dsuffix) + strlen(name[i]) + 12; data/sxiv-26/options.c:148:36: [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 (s == NULL || *s == '\0' || strlen(optarg) != 1) data/sxiv-26/thumbs.c:47: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 (strncmp(filepath, cache_dir, strlen(cache_dir)) != 0) { data/sxiv-26/thumbs.c:49:9: [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(cache_dir) + strlen(filepath) + 2; data/sxiv-26/thumbs.c:49:29: [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(cache_dir) + strlen(filepath) + 2; data/sxiv-26/thumbs.c:132: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). dirlen = strlen(cache_dir); data/sxiv-26/thumbs.c:175:9: [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(homedir) + strlen(dsuffix) + 6; data/sxiv-26/thumbs.c:175: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). len = strlen(homedir) + strlen(dsuffix) + 6; data/sxiv-26/util.c:51: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). size_t n = strlen(s) + 1; data/sxiv-26/util.c:155: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(rdir->name) + strlen(dentry->d_name) + 2; data/sxiv-26/util.c:155:31: [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(rdir->name) + strlen(dentry->d_name) + 2; data/sxiv-26/util.c:158:24: [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). rdir->name[strlen(rdir->name)-1] == '/' ? "" : "/", data/sxiv-26/window.c:406: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). if ((len = strlen(r->buf)) > 0) { data/sxiv-26/window.c:413: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). if ((len = strlen(l->buf)) > 0) { data/sxiv-26/window.c:453:60: [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). PropModeReplace, (unsigned char *) title, strlen(title)); data/sxiv-26/window.c:456:60: [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). PropModeReplace, (unsigned char *) title, strlen(title)); ANALYSIS SUMMARY: Hits = 45 Lines analyzed = 4735 in approximately 0.16 seconds (30487 lines/second) Physical Source Lines of Code (SLOC) = 3840 Hits@level = [0] 13 [1] 23 [2] 7 [3] 6 [4] 9 [5] 0 Hits@level+ = [0+] 58 [1+] 45 [2+] 22 [3+] 15 [4+] 9 [5+] 0 Hits/KSLOC@level+ = [0+] 15.1042 [1+] 11.7188 [2+] 5.72917 [3+] 3.90625 [4+] 2.34375 [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.