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/darcs-2.14.5/src/atomic_create.c Examining data/darcs-2.14.5/src/atomic_create.h Examining data/darcs-2.14.5/src/hscurl.c Examining data/darcs-2.14.5/src/hscurl.h Examining data/darcs-2.14.5/src/maybe_relink.c Examining data/darcs-2.14.5/src/maybe_relink.h Examining data/darcs-2.14.5/src/system_encoding.c Examining data/darcs-2.14.5/src/system_encoding.h Examining data/darcs-2.14.5/src/umask.c Examining data/darcs-2.14.5/src/umask.h Examining data/darcs-2.14.5/src/win32/send_email.c Examining data/darcs-2.14.5/src/win32/send_email.h Examining data/darcs-2.14.5/src/win32/sys/mman.h FINAL RESULTS: data/darcs-2.14.5/src/atomic_create.c:172:19: [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 *s = getenv("DARCS_SLOPPY_LOCKS"); data/darcs-2.14.5/src/hscurl.c:134:19: [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. proxypass = getenv("DARCS_PROXYUSERPWD"); data/darcs-2.14.5/src/hscurl.c:351:15: [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. stime_out = getenv("DARCS_CONNECTION_TIMEOUT"); data/darcs-2.14.5/src/win32/send_email.c:174:17: [3] (misc) LoadLibrary: Ensure that the full path to the library is specified, or current directory may be used (CWE-829, CWE-20). Use registry entry or GetWindowsDirectory to find library path, if you aren't already. funs->dll = LoadLibrary(name); data/darcs-2.14.5/src/atomic_create.c:39:10: [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). fd = open(p, O_WRONLY | O_EXCL | O_CREAT, 0666); data/darcs-2.14.5/src/atomic_create.c:64: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 hostname[65] = {'\0'}; data/darcs-2.14.5/src/atomic_create.c:80:13: [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(hostname, "kremvax"); data/darcs-2.14.5/src/atomic_create.c:100:9: [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(filename, p, dirlen); data/darcs-2.14.5/src/atomic_create.c:114:10: [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). fd = open(filename, O_WRONLY | O_EXCL | O_CREAT, 0666); data/darcs-2.14.5/src/atomic_create.h:10:5: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int mkstemp(char *p); data/darcs-2.14.5/src/hscurl.c:169:20: [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). url_data->file = fopen(filename,"wb"); data/darcs-2.14.5/src/hscurl.c:229: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[40]; data/darcs-2.14.5/src/hscurl.c:353:19: [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). long result = atol (stime_out); data/darcs-2.14.5/src/maybe_relink.c:128: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 buf1[RELINK_BUFFER_SIZE], buf2[RELINK_BUFFER_SIZE]; data/darcs-2.14.5/src/maybe_relink.c:130:15: [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). fd1 = open(tempname, O_RDONLY); data/darcs-2.14.5/src/maybe_relink.c:132:15: [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). fd2 = open(dst, O_RDONLY); data/darcs-2.14.5/src/win32/send_email.c:157:9: [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(desc, *desc_lookup, sizeof(MapiRecipDesc)); data/darcs-2.14.5/src/maybe_relink.c:96:10: [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). rc = strlen(dst) + 6; data/darcs-2.14.5/src/maybe_relink.c:140:19: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). rc1 = read(fd1, buf1, RELINK_BUFFER_SIZE); data/darcs-2.14.5/src/maybe_relink.c:142:19: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). rc2 = read(fd2, buf2, RELINK_BUFFER_SIZE); data/darcs-2.14.5/src/umask.c:21:10: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). rc = umask(mask); data/darcs-2.14.5/src/umask.c:33:5: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(old_mask); data/darcs-2.14.5/src/win32/send_email.c:64: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). if (ccname && strlen(ccname) > 0) { ANALYSIS SUMMARY: Hits = 23 Lines analyzed = 1040 in approximately 0.25 seconds (4241 lines/second) Physical Source Lines of Code (SLOC) = 774 Hits@level = [0] 33 [1] 6 [2] 13 [3] 4 [4] 0 [5] 0 Hits@level+ = [0+] 56 [1+] 23 [2+] 17 [3+] 4 [4+] 0 [5+] 0 Hits/KSLOC@level+ = [0+] 72.3514 [1+] 29.7158 [2+] 21.9638 [3+] 5.16796 [4+] 0 [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.