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/faketime-0.9.7/src/faketime_common.h Examining data/faketime-0.9.7/src/sunos_endian.h Examining data/faketime-0.9.7/src/time_ops.h Examining data/faketime-0.9.7/src/libfaketime.c Examining data/faketime-0.9.7/src/faketime.c Examining data/faketime-0.9.7/test/timetest.c FINAL RESULTS: data/faketime-0.9.7/src/faketime.c:172:27: [4] (shell) execlp: 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. if (EXIT_SUCCESS != execlp(date_cmd, date_cmd, "-d", argv[curr_opt], "+%s",(char *) NULL)) data/faketime-0.9.7/src/faketime.c:347:25: [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. if (EXIT_SUCCESS != execvp(argv[curr_opt], &argv[curr_opt])) data/faketime-0.9.7/src/libfaketime.c:2064:19: [4] (shell) system: 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. (void) (system(ft_spawn_target) + 1); data/faketime-0.9.7/src/faketime.c:312:43: [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 *ld_preload_new, *ld_preload = getenv("LD_PRELOAD"); data/faketime-0.9.7/src/libfaketime.c:271:55: [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 sem_name[256], shm_name[256], *ft_shared_env = getenv("FAKETIME_SHARED"); data/faketime-0.9.7/src/libfaketime.c:1721:7: [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 (getenv("NO_FAKE_STAT")!=NULL) data/faketime-0.9.7/src/libfaketime.c:1727:18: [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 ((tmp_env = getenv("FAKETIME_CACHE_DURATION")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1731:18: [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 ((tmp_env = getenv("FAKETIME_NO_CACHE")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1738:18: [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 ((tmp_env = getenv("DONT_FAKE_MONOTONIC")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1748:18: [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 ((tmp_env = getenv("FAKETIME_SKIP_CMDS")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1777:18: [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 ((tmp_env = getenv("FAKETIME_ONLY_CMDS")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1782:9: [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 (getenv("FAKETIME_SKIP_CMDS") != NULL) data/faketime-0.9.7/src/libfaketime.c:1814:18: [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 ((tmp_env = getenv("FAKETIME_START_AFTER_SECONDS")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1819:18: [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 ((tmp_env = getenv("FAKETIME_STOP_AFTER_SECONDS")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1824:18: [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 ((tmp_env = getenv("FAKETIME_START_AFTER_NUMCALLS")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1829:18: [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 ((tmp_env = getenv("FAKETIME_STOP_AFTER_NUMCALLS")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1836:18: [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 ((tmp_env = getenv("FAKETIME_SPAWN_TARGET")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1839:37: [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. (void) strncpy(ft_spawn_target, getenv("FAKETIME_SPAWN_TARGET"), sizeof(ft_spawn_target) - 1); data/faketime-0.9.7/src/libfaketime.c:1841:20: [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 ((tmp_env = getenv("FAKETIME_SPAWN_SECONDS")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1845:20: [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 ((tmp_env = getenv("FAKETIME_SPAWN_NUMCALLS")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1851:18: [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 ((tmp_env = getenv("FAKETIME_SAVE_FILE")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1862:18: [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 ((tmp_env = getenv("FAKETIME_LOAD_FILE")) != NULL) data/faketime-0.9.7/src/libfaketime.c:1894: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. tmp_env = getenv("FAKETIME_FMT"); data/faketime-0.9.7/src/libfaketime.c:1934:26: [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 (NULL != (tmp_env = getenv("FAKETIME"))) data/faketime-0.9.7/src/libfaketime.c:2097:28: [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 (NULL != (tmp_env = getenv("FAKETIME"))) data/faketime-0.9.7/src/libfaketime.c:2118:54: [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. (void) snprintf(custom_filename, BUFSIZ, "%s", getenv("FAKETIME_TIMESTAMP_FILE")); data/faketime-0.9.7/src/libfaketime.c:2119: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. (void) snprintf(filename, BUFSIZ, "%s/.faketimerc", getenv("HOME")); data/faketime-0.9.7/src/faketime.c:62: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 sem_name[PATH_BUFSIZE] = {0}, shm_name[PATH_BUFSIZE] = {0}; data/faketime-0.9.7/src/faketime.c:180:7: [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[256] = {0}; /* e will have way less than 256 digits */ data/faketime-0.9.7/src/faketime.c:190:16: [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). offset = atol(buf) - time(NULL); data/faketime-0.9.7/src/faketime.c:212:5: [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 shared_objs[PATH_BUFSIZE * 2 + 1]; data/faketime-0.9.7/src/faketime.c:299: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). check = fopen(ftpl_path, "ro"); data/faketime-0.9.7/src/libfaketime.c:219: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. static char ft_spawn_target[1024]; data/faketime-0.9.7/src/libfaketime.c:237: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. static char user_faked_time_fmt[BUFSIZ] = {0}; data/faketime-0.9.7/src/libfaketime.c:243: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. static char user_faked_time_saved[BUFFERLEN] = {0}; data/faketime-0.9.7/src/libfaketime.c:271: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 sem_name[256], shm_name[256], *ft_shared_env = getenv("FAKETIME_SHARED"); data/faketime-0.9.7/src/libfaketime.c:1729:22: [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). cache_duration = atoi(tmp_env); data/faketime-0.9.7/src/libfaketime.c:1816:27: [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). ft_start_after_secs = atol(tmp_env); data/faketime-0.9.7/src/libfaketime.c:1821:26: [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). ft_stop_after_secs = atol(tmp_env); data/faketime-0.9.7/src/libfaketime.c:1826:29: [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). ft_start_after_ncalls = atol(tmp_env); data/faketime-0.9.7/src/libfaketime.c:1831:28: [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). ft_stop_after_ncalls = atol(tmp_env); data/faketime-0.9.7/src/libfaketime.c:1843:23: [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). ft_spawn_secs = atol(tmp_env); data/faketime-0.9.7/src/libfaketime.c:1847:25: [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). ft_spawn_ncalls = atol(tmp_env); data/faketime-0.9.7/src/libfaketime.c:1853:26: [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). if (-1 == (outfile = open(tmp_env, O_RDWR | O_APPEND | O_CLOEXEC | O_CREAT, data/faketime-0.9.7/src/libfaketime.c:1866:25: [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). if (-1 == (infile = open(tmp_env, O_RDONLY|O_CLOEXEC))) data/faketime-0.9.7/src/libfaketime.c:1897:5: [2] (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). Risk is low because the source is a constant string. strcpy(user_faked_time_fmt, "%Y-%m-%d %T"); data/faketime-0.9.7/src/libfaketime.c:2089:12: [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. static char user_faked_time[BUFFERLEN]; /* changed to static for caching in v0.6 */ data/faketime-0.9.7/src/libfaketime.c:2111:7: [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 custom_filename[BUFSIZ]; data/faketime-0.9.7/src/libfaketime.c:2112:7: [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 filename[BUFSIZ]; data/faketime-0.9.7/src/libfaketime.c:2120:25: [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 ((faketimerc = fopen(custom_filename, "rt")) != NULL || data/faketime-0.9.7/src/libfaketime.c:2121:25: [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). (faketimerc = fopen(filename, "rt")) != NULL || data/faketime-0.9.7/src/libfaketime.c:2122:25: [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). (faketimerc = fopen("/etc/faketimerc", "rt")) != NULL) data/faketime-0.9.7/src/libfaketime.c:2124:9: [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[BUFFERLEN]; data/faketime-0.9.7/src/faketime.c:182:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). (void) (read(pfds[0], buf, 256) + 1); data/faketime-0.9.7/src/faketime.c:333: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 = ((ld_preload)?strlen(ld_preload) + 1: 0) + 1 + strlen(ftpl_path); data/faketime-0.9.7/src/faketime.c:333: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). len = ((ld_preload)?strlen(ld_preload) + 1: 0) + 1 + strlen(ftpl_path); data/faketime-0.9.7/src/faketime.c:359:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). (void) (read(keepalive_fds[0], &buf, 1) + 1); /* reads 0B when all children exit */ data/faketime-0.9.7/src/libfaketime.c:275:9: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (sscanf(ft_shared_env, "%255s %255s", sem_name, shm_name) < 2) data/faketime-0.9.7/src/libfaketime.c:858:5: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. int usleep(useconds_t usec) data/faketime-0.9.7/src/libfaketime.c:1625:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(user_faked_time_saved, user_faked_time, BUFFERLEN-1); data/faketime-0.9.7/src/libfaketime.c:1839:12: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). (void) strncpy(ft_spawn_target, getenv("FAKETIME_SPAWN_TARGET"), sizeof(ft_spawn_target) - 1); data/faketime-0.9.7/src/libfaketime.c:1901:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(user_faked_time_fmt, tmp_env, BUFSIZ - 1); data/faketime-0.9.7/src/libfaketime.c:1952: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). char *endp = line + strlen(line); data/faketime-0.9.7/src/libfaketime.c:2099:7: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(user_faked_time, tmp_env, BUFFERLEN - 1); data/faketime-0.9.7/src/libfaketime.c:2127: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). if ((strlen(line) > 1) && (line[0] != ' ') && data/faketime-0.9.7/src/libfaketime.c:2131:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(user_faked_time, line, BUFFERLEN-1); data/faketime-0.9.7/test/timetest.c:154:9: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(1000000); ANALYSIS SUMMARY: Hits = 67 Lines analyzed = 3210 in approximately 0.13 seconds (24014 lines/second) Physical Source Lines of Code (SLOC) = 2383 Hits@level = [0] 50 [1] 14 [2] 26 [3] 24 [4] 3 [5] 0 Hits@level+ = [0+] 117 [1+] 67 [2+] 53 [3+] 27 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 49.0978 [1+] 28.1158 [2+] 22.2409 [3+] 11.3303 [4+] 1.25892 [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.