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/sxhkd-0.6.2/src/grab.c Examining data/sxhkd-0.6.2/src/grab.h Examining data/sxhkd-0.6.2/src/helpers.c Examining data/sxhkd-0.6.2/src/helpers.h Examining data/sxhkd-0.6.2/src/locales.h Examining data/sxhkd-0.6.2/src/parse.c Examining data/sxhkd-0.6.2/src/parse.h Examining data/sxhkd-0.6.2/src/sxhkd.c Examining data/sxhkd-0.6.2/src/sxhkd.h Examining data/sxhkd-0.6.2/src/types.c Examining data/sxhkd-0.6.2/src/types.h FINAL RESULTS: data/sxhkd-0.6.2/src/helpers.c:39:2: [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/sxhkd-0.6.2/src/helpers.c:48:2: [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/sxhkd-0.6.2/src/helpers.c:83:2: [4] (shell) execvp: 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. execvp(cmd[0], cmd); data/sxhkd-0.6.2/src/helpers.h:33:27: [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. # define PRINTF(x,...) printf(x, __VA_ARGS__) data/sxhkd-0.6.2/src/parse.c:2570: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(dest + i, c->item); data/sxhkd-0.6.2/src/parse.c:2574:4: [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(dest + i, c->text); data/sxhkd-0.6.2/src/parse.c:2718:10: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. return (sscanf(name, "button%" SCNu8, butidx) == 1); data/sxhkd-0.6.2/src/sxhkd.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, "hvm:t:c:r:s:a:")) != -1) { data/sxhkd-0.6.2/src/sxhkd.c:115:23: [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. char *config_home = getenv(CONFIG_HOME_ENV); data/sxhkd-0.6.2/src/sxhkd.c:119:59: [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. snprintf(config_file, sizeof(config_file), "%s/%s/%s", getenv("HOME"), ".config", CONFIG_PATH); data/sxhkd-0.6.2/src/sxhkd.c:295:15: [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 ((shell = getenv(SXHKD_SHELL_ENV)) == NULL && (shell = getenv(SHELL_ENV)) == NULL) data/sxhkd-0.6.2/src/sxhkd.c:295:60: [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 ((shell = getenv(SXHKD_SHELL_ENV)) == NULL && (shell = getenv(SHELL_ENV)) == NULL) data/sxhkd-0.6.2/src/parse.c:2374: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). FILE *cfg = fopen(config_file, "r"); data/sxhkd-0.6.2/src/parse.c:2378: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[3 * MAXLEN]; data/sxhkd-0.6.2/src/parse.c:2379: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 chain[MAXLEN] = {0}; data/sxhkd-0.6.2/src/parse.c:2380: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 command[2 * MAXLEN] = {0}; data/sxhkd-0.6.2/src/parse.c:2447: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 hotkey[2 * MAXLEN] = {0}; data/sxhkd-0.6.2/src/parse.c:2448: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 command[2 * MAXLEN] = {0}; data/sxhkd-0.6.2/src/parse.c:2449: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 last_hotkey[2 * MAXLEN] = {0}; data/sxhkd-0.6.2/src/parse.c:2653: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 chord[MAXLEN] = {0}; data/sxhkd-0.6.2/src/parse.c:2654: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[MAXLEN] = {0}; data/sxhkd-0.6.2/src/parse.c:2655: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 ignored[MAXLEN] = {0}; data/sxhkd-0.6.2/src/parse.h:45: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 text[2 * MAXLEN]; data/sxhkd-0.6.2/src/parse.h:46: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 item[2 * MAXLEN]; data/sxhkd-0.6.2/src/sxhkd.c:44:1: [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 config_file[MAXLEN]; data/sxhkd-0.6.2/src/sxhkd.c:50:1: [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 progress[3 * MAXLEN]; data/sxhkd-0.6.2/src/sxhkd.c:90:15: [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). timeout = atoi(optarg); data/sxhkd-0.6.2/src/sxhkd.c:96: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). redir_fd = open(optarg, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); data/sxhkd-0.6.2/src/sxhkd.c:125:17: [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 fifo_fd = open(fifo_path, O_RDWR | O_NONBLOCK); data/sxhkd-0.6.2/src/sxhkd.h:50: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. extern char config_file[MAXLEN]; data/sxhkd-0.6.2/src/sxhkd.h:56: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. extern char progress[3 * MAXLEN]; data/sxhkd-0.6.2/src/types.h:41: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 repr[MAXLEN]; data/sxhkd-0.6.2/src/types.h:66: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 command[2 * MAXLEN]; data/sxhkd-0.6.2/src/helpers.c:89:15: [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 len = strlen(s); data/sxhkd-0.6.2/src/helpers.c:101: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 i = strlen(s) - 1; data/sxhkd-0.6.2/src/parse.c:2386: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). if (strlen(buf) < 2 || first == START_COMMENT) { data/sxhkd-0.6.2/src/parse.c:2407: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). if (isspace(first) && strlen(chain) > 0 && strlen(command) > 0) { data/sxhkd-0.6.2/src/parse.c:2407: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). if (isspace(first) && strlen(chain) > 0 && strlen(command) > 0) { data/sxhkd-0.6.2/src/parse.c:2504:15: [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 len = strlen(src); data/sxhkd-0.6.2/src/parse.c:2563: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). if (c->range_cur > c->range_max && strlen(c->item) == 3) data/sxhkd-0.6.2/src/parse.c:2571: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). i += strlen(c->item); data/sxhkd-0.6.2/src/parse.c:2575: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). i += strlen(c->text); data/sxhkd-0.6.2/src/parse.c:2585:15: [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 len = strlen(s); data/sxhkd-0.6.2/src/parse.c:2772: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). snprintf(folded_string, strlen(string), "%s", string); data/sxhkd-0.6.2/src/types.c:48:6: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is low because the source is a constant character. strncat(progress, ";", sizeof(progress) - strlen(progress) - 1); data/sxhkd-0.6.2/src/types.c:48:48: [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). strncat(progress, ";", sizeof(progress) - strlen(progress) - 1); data/sxhkd-0.6.2/src/types.c:49:6: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(progress, c->state->repr, sizeof(progress) - strlen(progress) - 1); data/sxhkd-0.6.2/src/types.c:49:59: [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). strncat(progress, c->state->repr, sizeof(progress) - strlen(progress) - 1); ANALYSIS SUMMARY: Hits = 48 Lines analyzed = 4089 in approximately 0.15 seconds (27090 lines/second) Physical Source Lines of Code (SLOC) = 3690 Hits@level = [0] 16 [1] 15 [2] 21 [3] 5 [4] 7 [5] 0 Hits@level+ = [0+] 64 [1+] 48 [2+] 33 [3+] 12 [4+] 7 [5+] 0 Hits/KSLOC@level+ = [0+] 17.3442 [1+] 13.0081 [2+] 8.94309 [3+] 3.25203 [4+] 1.89702 [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.