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/wmwork-0.2.6/src/wmwork.c Examining data/wmwork-0.2.6/src/wmwork.h Examining data/wmwork-0.2.6/src/wmgeneral.c Examining data/wmwork-0.2.6/src/wmgeneral.h FINAL RESULTS: data/wmwork-0.2.6/src/wmwork.c:663:25: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. if (i == 1 && ((i = readlink(proc, buffer, sizeof(buffer)-1)) >= 0 || errno == ENOENT)) { data/wmwork-0.2.6/src/wmwork.c:660:9: [4] (buffer) fscanf: 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. i = fscanf(F, PID_T, &pid); data/wmwork-0.2.6/src/wmwork.c:679:3: [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(F, PID_T"\n", getpid()); data/wmwork-0.2.6/src/wmwork.c:101:6: [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("HOME") == NULL || *getenv("HOME") == 0) { data/wmwork-0.2.6/src/wmwork.c:101:33: [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("HOME") == NULL || *getenv("HOME") == 0) { data/wmwork-0.2.6/src/wmwork.c:109: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. path_len = strlen(getenv("HOME")) + strlen("/.wmwork/worklog") + 1; data/wmwork-0.2.6/src/wmwork.c:115:45: [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(dirName, path_len, "%s/.wmwork", getenv("HOME")); data/wmwork-0.2.6/src/wmwork.c:327: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 ((i = getopt_long(argc, argv, "dfhv", long_opts, &opt_index)) == -1) data/wmwork-0.2.6/src/wmwork.c:629:45: [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(fname, path_len, "%s/.wmwork/%s", getenv("HOME"), current->name); data/wmwork-0.2.6/src/wmwork.c:703:45: [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(temp1, path_len, "%s/.wmworklog", getenv("HOME")); data/wmwork-0.2.6/src/wmwork.c:713: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 ((dir = opendir(getenv("HOME"))) < 0) { data/wmwork-0.2.6/src/wmwork.c:714: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. fprintf(stderr, "%s: cannot read '%s'\n", PACKAGE_NAME, getenv("HOME")); data/wmwork-0.2.6/src/wmwork.c:721:39: [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(temp1, path_len, "%s/%s", getenv("HOME"), entry->d_name); data/wmwork-0.2.6/src/wmgeneral.c:121: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 temp[128]; data/wmwork-0.2.6/src/wmgeneral.c:126: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(filename, "r"); data/wmwork-0.2.6/src/wmgeneral.c:156: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 temp[128]; data/wmwork-0.2.6/src/wmgeneral.c:162: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(filename, "r"); data/wmwork-0.2.6/src/wmgeneral.c:324: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(zero, xpm[1], chars); data/wmwork-0.2.6/src/wmgeneral.c:331: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(color, pos, chars); data/wmwork-0.2.6/src/wmwork.c:49: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 data/wmwork-0.2.6/src/wmwork.c:493: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 data/wmwork-0.2.6/src/wmwork.c:504:2: [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(first->name, "---"); data/wmwork-0.2.6/src/wmwork.c:509: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(logname, "r")) == NULL) { data/wmwork-0.2.6/src/wmwork.c:586: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(logname, "w")) == NULL) { data/wmwork-0.2.6/src/wmwork.c:630: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(fname, "a")) == NULL) { data/wmwork-0.2.6/src/wmwork.c:657:12: [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 ((fd = open(lockname, O_WRONLY | O_CREAT | (force ? 0 : O_EXCL), 0666)) < 0) { data/wmwork-0.2.6/src/wmwork.c:659: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 ((F = fopen(lockname, "r")) != NULL) { data/wmwork-0.2.6/src/wmwork.h:12: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[4]; data/wmwork-0.2.6/src/wmgeneral.c:135: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). p += strlen(keys[key].label); data/wmwork-0.2.6/src/wmgeneral.c:168: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). p += strlen(keys[key].label); data/wmwork-0.2.6/src/wmwork.c:106:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(077); data/wmwork-0.2.6/src/wmwork.c:109: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). path_len = strlen(getenv("HOME")) + strlen("/.wmwork/worklog") + 1; data/wmwork-0.2.6/src/wmwork.c:109:38: [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). path_len = strlen(getenv("HOME")) + strlen("/.wmwork/worklog") + 1; data/wmwork-0.2.6/src/wmwork.c:231:3: [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(50000L); data/wmwork-0.2.6/src/wmwork.c:476:12: [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 (i >= strlen(name)) data/wmwork-0.2.6/src/wmwork.c:720:4: [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). strlen(entry->d_name) > 8 && strlen(entry->d_name) <= 11) { data/wmwork-0.2.6/src/wmwork.c:720:33: [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). strlen(entry->d_name) > 8 && strlen(entry->d_name) <= 11) { ANALYSIS SUMMARY: Hits = 37 Lines analyzed = 1316 in approximately 0.05 seconds (26212 lines/second) Physical Source Lines of Code (SLOC) = 1001 Hits@level = [0] 76 [1] 9 [2] 15 [3] 10 [4] 2 [5] 1 Hits@level+ = [0+] 113 [1+] 37 [2+] 28 [3+] 13 [4+] 3 [5+] 1 Hits/KSLOC@level+ = [0+] 112.887 [1+] 36.963 [2+] 27.972 [3+] 12.987 [4+] 2.997 [5+] 0.999001 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.