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/wmweather-2.4.7/src/wmweather.c Examining data/wmweather-2.4.7/src/wmgeneral.c Examining data/wmweather-2.4.7/src/wmgeneral.h FINAL RESULTS: data/wmweather-2.4.7/src/wmweather.c:115:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(report, "%s/.wmweather", getenv("HOME")); data/wmweather-2.4.7/src/wmweather.c:140:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(rindex(report, '/'), "/%s", station); data/wmweather-2.4.7/src/wmweather.c:229:6: [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. if (execl(XMESSAGE, "xmessage", "-center", "-file", report, "-title", xtitle, NULL) < 0) { data/wmweather-2.4.7/src/wmweather.c:574:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(temp, "%s.new", report); data/wmweather-2.4.7/src/wmweather.c:113:25: [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. report = malloc(strlen(getenv("HOME")) + strlen("/.wmweather/config") + 1); data/wmweather-2.4.7/src/wmweather.c:115:35: [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. sprintf(report, "%s/.wmweather", getenv("HOME")); data/wmweather-2.4.7/src/wmweather.c:399: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, "s:d:makgbnpwWeut:x:U:chv", long_opts, NULL)) == -1) data/wmweather-2.4.7/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/wmweather-2.4.7/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/wmweather-2.4.7/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/wmweather-2.4.7/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/wmweather-2.4.7/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/wmweather-2.4.7/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/wmweather-2.4.7/src/wmweather.c:103: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/wmweather-2.4.7/src/wmweather.c:129:2: [2] (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). Risk is low because the source is a constant string. strcat(report, "/config"); data/wmweather-2.4.7/src/wmweather.c:138: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(url + strlen(url), station, 4); data/wmweather-2.4.7/src/wmweather.c:139: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(xtitle + strlen(xtitle), station, 4); data/wmweather-2.4.7/src/wmweather.c:240: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/wmweather-2.4.7/src/wmweather.c:247: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(rcfile, "r")) == NULL) { data/wmweather-2.4.7/src/wmweather.c:576: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(temp, "w")) == NULL) { data/wmweather-2.4.7/src/wmweather.c:658: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. static char data/wmweather-2.4.7/src/wmweather.c:690: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 buffer[MAX_STRING], *i; data/wmweather-2.4.7/src/wmweather.c:709: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(report, "r"); data/wmweather-2.4.7/src/wmweather.c:718: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(id, "\0\0\0\0", 4); data/wmweather-2.4.7/src/wmweather.c:719: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(winddir, "\0\0\0", 3); data/wmweather-2.4.7/src/wmweather.c:792:6: [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(winddir, "VRB", 3); data/wmweather-2.4.7/src/wmweather.c:1326: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(&(mem->memory[mem->size]), ptr, real); data/wmweather-2.4.7/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/wmweather-2.4.7/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/wmweather-2.4.7/src/wmweather.c:113:18: [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). report = malloc(strlen(getenv("HOME")) + strlen("/.wmweather/config") + 1); data/wmweather-2.4.7/src/wmweather.c:113:43: [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). report = malloc(strlen(getenv("HOME")) + strlen("/.wmweather/config") + 1); data/wmweather-2.4.7/src/wmweather.c:137: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). assert(strlen(station) == 4); data/wmweather-2.4.7/src/wmweather.c:138: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). memcpy(url + strlen(url), station, 4); data/wmweather-2.4.7/src/wmweather.c:139:18: [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). memcpy(xtitle + strlen(xtitle), station, 4); data/wmweather-2.4.7/src/wmweather.c:213: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/wmweather-2.4.7/src/wmweather.c:267:8: [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(optarg) != 4) { data/wmweather-2.4.7/src/wmweather.c:324:24: [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). memset(optarg, '*', strlen(optarg)); data/wmweather-2.4.7/src/wmweather.c:404:8: [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(optarg) != 4) { data/wmweather-2.4.7/src/wmweather.c:478:24: [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). memset(optarg, '*', strlen(optarg)); data/wmweather-2.4.7/src/wmweather.c:572:17: [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). temp = malloc(strlen(report) + 5); ANALYSIS SUMMARY: Hits = 40 Lines analyzed = 1877 in approximately 0.06 seconds (28917 lines/second) Physical Source Lines of Code (SLOC) = 1544 Hits@level = [0] 75 [1] 13 [2] 20 [3] 3 [4] 4 [5] 0 Hits@level+ = [0+] 115 [1+] 40 [2+] 27 [3+] 7 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 74.4819 [1+] 25.9067 [2+] 17.487 [3+] 4.53368 [4+] 2.59067 [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.