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/9mount-1.3+hg20170412/9bind.c Examining data/9mount-1.3+hg20170412/9mount.c Examining data/9mount-1.3+hg20170412/9umount.c FINAL RESULTS: data/9mount-1.3+hg20170412/9bind.c:33:27: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (stat(new, &stbuf) || access(new, W_OK)) { data/9mount-1.3+hg20170412/9mount.c:48:2: [4] (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). strcat(*dest, src); data/9mount-1.3+hg20170412/9mount.c:101:7: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(*netaddr, R_OK | W_OK)) { data/9mount-1.3+hg20170412/9mount.c:168:31: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (stat(mountpt, &stbuf) || access(mountpt, W_OK)) { data/9mount-1.3+hg20170412/9umount.c:25:3: [4] (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). strcat(abs, rel); data/9mount-1.3+hg20170412/9umount.c:37:3: [4] (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). strcat(abs, cwd); data/9mount-1.3+hg20170412/9umount.c:39:3: [4] (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). strcat(abs, rel); data/9mount-1.3+hg20170412/9mount.c:239: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("USER")) { data/9mount-1.3+hg20170412/9mount.c:240:42: [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(buf, sizeof(buf), "uname=%s", getenv("USER")); data/9mount-1.3+hg20170412/9mount.c:84:13: [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). *port = atoi(service); data/9mount-1.3+hg20170412/9mount.c:110: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 buf[256], *opts, *dial = NULL, *mountpt = NULL; data/9mount-1.3+hg20170412/9umount.c:112:12: [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 (!(fp=fopen("/proc/mounts", "r"))) { data/9mount-1.3+hg20170412/9mount.c:41: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). while (strlen(*dest) + 1 + strlen(src) > *destlen) data/9mount-1.3+hg20170412/9mount.c:41:29: [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). while (strlen(*dest) + 1 + strlen(src) > *destlen) data/9mount-1.3+hg20170412/9mount.c:47:3: [1] (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 character. strcat(*dest, ","); data/9mount-1.3+hg20170412/9mount.c:83:41: [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 (strspn(service, "0123456789") == strlen(service)) { data/9mount-1.3+hg20170412/9umount.c:21:20: [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 (!(abs=malloc(strlen(rel) + 2))) { data/9mount-1.3+hg20170412/9umount.c:26:3: [1] (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 character. strcat(abs, "/"); data/9mount-1.3+hg20170412/9umount.c:32:20: [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 (!(abs=malloc(strlen(cwd) + 1 + strlen(rel) + 2))) { data/9mount-1.3+hg20170412/9umount.c:32: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). if (!(abs=malloc(strlen(cwd) + 1 + strlen(rel) + 2))) { data/9mount-1.3+hg20170412/9umount.c:38:3: [1] (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 character. strcat(abs, "/"); data/9mount-1.3+hg20170412/9umount.c:40:3: [1] (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 character. strcat(abs, "/"); data/9mount-1.3+hg20170412/9umount.c:49:22: [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). memmove(prev, cp, strlen(cp)+1); data/9mount-1.3+hg20170412/9umount.c:51:22: [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). memmove(prev, cp, strlen(cp)+1); data/9mount-1.3+hg20170412/9umount.c:59: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). memmove(parent, cp, strlen(cp)+1); data/9mount-1.3+hg20170412/9umount.c:65:6: [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). abs[strlen(abs)-1] = '\0'; /* remove trailing slash */ data/9mount-1.3+hg20170412/9umount.c:73:37: [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). return (strncmp(mnt->mnt_dir, dir, strlen(dir)) == 0); ANALYSIS SUMMARY: Hits = 27 Lines analyzed = 485 in approximately 0.02 seconds (21286 lines/second) Physical Source Lines of Code (SLOC) = 428 Hits@level = [0] 14 [1] 15 [2] 3 [3] 2 [4] 7 [5] 0 Hits@level+ = [0+] 41 [1+] 27 [2+] 12 [3+] 9 [4+] 7 [5+] 0 Hits/KSLOC@level+ = [0+] 95.7944 [1+] 63.0841 [2+] 28.0374 [3+] 21.028 [4+] 16.3551 [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.