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/redshift-1.12/src/location-corelocation.h Examining data/redshift-1.12/src/gamma-quartz.c Examining data/redshift-1.12/src/solar.c Examining data/redshift-1.12/src/gamma-vidmode.c Examining data/redshift-1.12/src/gamma-dummy.c Examining data/redshift-1.12/src/hooks.h Examining data/redshift-1.12/src/config-ini.c Examining data/redshift-1.12/src/gamma-w32gdi.h Examining data/redshift-1.12/src/location-manual.c Examining data/redshift-1.12/src/location-geoclue2.h Examining data/redshift-1.12/src/redshift.h Examining data/redshift-1.12/src/gamma-randr.h Examining data/redshift-1.12/src/colorramp.h Examining data/redshift-1.12/src/gamma-drm.h Examining data/redshift-1.12/src/pipeutils.c Examining data/redshift-1.12/src/signals.h Examining data/redshift-1.12/src/systemtime.c Examining data/redshift-1.12/src/options.h Examining data/redshift-1.12/src/gamma-quartz.h Examining data/redshift-1.12/src/location-manual.h Examining data/redshift-1.12/src/config-ini.h Examining data/redshift-1.12/src/gamma-w32gdi.c Examining data/redshift-1.12/src/hooks.c Examining data/redshift-1.12/src/gamma-dummy.h Examining data/redshift-1.12/src/solar.h Examining data/redshift-1.12/src/gamma-vidmode.h Examining data/redshift-1.12/src/gamma-randr.c Examining data/redshift-1.12/src/redshift.c Examining data/redshift-1.12/src/location-geoclue2.c Examining data/redshift-1.12/src/options.c Examining data/redshift-1.12/src/systemtime.h Examining data/redshift-1.12/src/pipeutils.h Examining data/redshift-1.12/src/gamma-drm.c Examining data/redshift-1.12/src/colorramp.c Examining data/redshift-1.12/src/signals.c FINAL RESULTS: data/redshift-1.12/src/gamma-drm.c:90:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(pathname, DRM_DEV_NAME, DRM_DIR_NAME, state->card_num); data/redshift-1.12/src/hooks.c:102:12: [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. int r = execl(hook_path, hook_name, data/redshift-1.12/src/config-ini.c:64:27: [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 (f == NULL && (env = getenv("XDG_CONFIG_HOME")) != NULL && data/redshift-1.12/src/config-ini.c:78:27: [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 (f == NULL && (env = getenv("localappdata")) != NULL && data/redshift-1.12/src/config-ini.c:85:27: [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 (f == NULL && (env = getenv("HOME")) != NULL && data/redshift-1.12/src/config-ini.c:113:27: [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 (f == NULL && (env = getenv("XDG_CONFIG_DIRS")) != NULL && data/redshift-1.12/src/hooks.c:52: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. if ((env = getenv("XDG_CONFIG_HOME")) != NULL && data/redshift-1.12/src/hooks.c:58: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. if ((env = getenv("HOME")) != NULL && data/redshift-1.12/src/options.c:498: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, "b:c:g:hl:m:oO:pPrt:vVx")) != -1) { data/redshift-1.12/src/config-ini.c:61:3: [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 cp[MAX_CONFIG_PATH]; data/redshift-1.12/src/config-ini.c:68:8: [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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:73:9: [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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:82:8: [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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:89:8: [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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:94:9: [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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:104:8: [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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:109:9: [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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:124:10: [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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:129: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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:142:8: [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). f = fopen(cp, "r"); data/redshift-1.12/src/config-ini.c:148: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). f = fopen(filepath, "r"); data/redshift-1.12/src/config-ini.c:171: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 line[MAX_LINE_LENGTH]; data/redshift-1.12/src/config-ini.c:222: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(section->name, name, end - name + 1); data/redshift-1.12/src/config-ini.c:268: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(setting->name, s, end - s + 1); data/redshift-1.12/src/config-ini.c:279: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(setting->value, value, value_len); data/redshift-1.12/src/gamma-drm.c:88: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 pathname[maxlen]; data/redshift-1.12/src/gamma-drm.c:92: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). state->fd = open(pathname, O_RDWR | O_CLOEXEC); data/redshift-1.12/src/gamma-drm.c:256:21: [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). state->card_num = atoi(value); data/redshift-1.12/src/gamma-drm.c:258:21: [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). state->crtc_num = atoi(value); data/redshift-1.12/src/gamma-quartz.c:211: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(gamma_ramps, state->displays[display_index].saved_ramps, data/redshift-1.12/src/gamma-randr.c:240: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(&state->crtcs[i].saved_ramps[0*ramp_size], gamma_r, data/redshift-1.12/src/gamma-randr.c:242: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(&state->crtcs[i].saved_ramps[1*ramp_size], gamma_g, data/redshift-1.12/src/gamma-randr.c:244: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(&state->crtcs[i].saved_ramps[2*ramp_size], gamma_b, data/redshift-1.12/src/gamma-randr.c:317:23: [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). state->screen_num = atoi(value); data/redshift-1.12/src/gamma-randr.c:412: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(gamma_ramps, state->crtcs[crtc_num].saved_ramps, data/redshift-1.12/src/gamma-vidmode.c:154:23: [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). state->screen_num = atoi(value); data/redshift-1.12/src/gamma-vidmode.c:204: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(gamma_ramps, state->saved_ramps, data/redshift-1.12/src/gamma-w32gdi.c:186: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(gamma_ramps, state->saved_ramps, data/redshift-1.12/src/hooks.c:77: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 hooksdir_path[MAX_HOOK_PATH]; data/redshift-1.12/src/hooks.c:87:3: [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 hook_path[MAX_HOOK_PATH]; data/redshift-1.12/src/options.c:448:23: [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). options->temp_set = atoi(value); data/redshift-1.12/src/options.c:467: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). options->scheme.day.temperature = atoi(value); data/redshift-1.12/src/options.c:468:39: [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). options->scheme.night.temperature = atoi(s); data/redshift-1.12/src/options.c:516:38: [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). options->scheme.day.temperature = atoi(value); data/redshift-1.12/src/options.c:520:40: [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). options->scheme.night.temperature = atoi(value); data/redshift-1.12/src/options.c:527:26: [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). options->use_fade = !!atoi(value); data/redshift-1.12/src/config-ini.c:271:23: [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 value_len = strlen(value) + 1; data/redshift-1.12/src/gamma-drm.c:87:16: [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). long maxlen = strlen(DRM_DIR_NAME) + strlen(DRM_DEV_NAME) + 10; data/redshift-1.12/src/gamma-drm.c:87: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). long maxlen = strlen(DRM_DIR_NAME) + strlen(DRM_DEV_NAME) + 10; data/redshift-1.12/src/pipeutils.c:97:2: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(read_fd, &data, 1); ANALYSIS SUMMARY: Hits = 50 Lines analyzed = 6328 in approximately 0.22 seconds (28479 lines/second) Physical Source Lines of Code (SLOC) = 4332 Hits@level = [0] 113 [1] 4 [2] 37 [3] 7 [4] 2 [5] 0 Hits@level+ = [0+] 163 [1+] 50 [2+] 46 [3+] 9 [4+] 2 [5+] 0 Hits/KSLOC@level+ = [0+] 37.627 [1+] 11.542 [2+] 10.6187 [3+] 2.07756 [4+] 0.461681 [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.