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/brightnessctl-0.5.1/brightnessctl.c FINAL RESULTS: data/brightnessctl-0.5.1/brightnessctl.c:220: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(file_path, W_OK)) { data/brightnessctl-0.5.1/brightnessctl.c:337: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(stdout, format, data/brightnessctl-0.5.1/brightnessctl.c:607: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(buf, curr); data/brightnessctl-0.5.1/brightnessctl.c:610:4: [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(buf, split); data/brightnessctl-0.5.1/brightnessctl.c:631: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, err_msg, va); data/brightnessctl-0.5.1/brightnessctl.c:125:12: [3] (buffer) getopt_long: 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. if ((c = getopt_long(argc, argv, "lqpmn::e::srhVc:d:", options, NULL)) < 0) data/brightnessctl-0.5.1/brightnessctl.c:231:21: [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 ((sys_run_dir = getenv("XDG_RUNTIME_DIR"))) data/brightnessctl-0.5.1/brightnessctl.c:148:13: [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). p.min = atol(optarg); data/brightnessctl-0.5.1/brightnessctl.c:402: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 c[16]; data/brightnessctl-0.5.1/brightnessctl.c:403:13: [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. size_t s = sprintf(c, "%u", d->curr_brightness); data/brightnessctl-0.5.1/brightnessctl.c:409: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). if ((f = fopen(dir_child(device_path(d), "brightness"), "w"))) { data/brightnessctl-0.5.1/brightnessctl.c:441: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). if (!(f = fopen(ent_path = dir_child(dev_path, ent->d_name), "r"))) data/brightnessctl-0.5.1/brightnessctl.c:505: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 c[16]; data/brightnessctl-0.5.1/brightnessctl.c:506:13: [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. size_t s = sprintf(c, "%u", dev->curr_brightness); data/brightnessctl-0.5.1/brightnessctl.c:520: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). fp = fopen(d_path, "w"); data/brightnessctl-0.5.1/brightnessctl.c:539: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[16]; data/brightnessctl-0.5.1/brightnessctl.c:545:13: [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 (!(fp = fopen(filename, "r"))) data/brightnessctl-0.5.1/brightnessctl.c:599: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 split[2] = {c, '\0'}; data/brightnessctl-0.5.1/brightnessctl.c:519:8: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). old = umask(0); data/brightnessctl-0.5.1/brightnessctl.c:521:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(old); data/brightnessctl-0.5.1/brightnessctl.c:604: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). length += strlen(curr); ANALYSIS SUMMARY: Hits = 21 Lines analyzed = 668 in approximately 0.03 seconds (24199 lines/second) Physical Source Lines of Code (SLOC) = 595 Hits@level = [0] 16 [1] 3 [2] 11 [3] 2 [4] 5 [5] 0 Hits@level+ = [0+] 37 [1+] 21 [2+] 18 [3+] 7 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 62.1849 [1+] 35.2941 [2+] 30.2521 [3+] 11.7647 [4+] 8.40336 [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.