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/cado-0.9.5/include/cado_const.h Examining data/cado-0.9.5/include/cado_paths.h Examining data/cado-0.9.5/include/cado_scado_check.h Examining data/cado-0.9.5/include/capset_from_namelist.h Examining data/cado-0.9.5/include/compute_digest.h Examining data/cado-0.9.5/include/file_utils.h Examining data/cado-0.9.5/include/get_scado_file.h Examining data/cado-0.9.5/include/get_user_groups.h Examining data/cado-0.9.5/include/pam_check.h Examining data/cado-0.9.5/include/read_conf.h Examining data/cado-0.9.5/include/scado_parse.h Examining data/cado-0.9.5/include/set_ambient_cap.h Examining data/cado-0.9.5/src/cado.c Examining data/cado-0.9.5/src/cado_scado_check.c Examining data/cado-0.9.5/src/cadrop.c Examining data/cado-0.9.5/src/caprint.c Examining data/cado-0.9.5/src/capset_from_namelist.c Examining data/cado-0.9.5/src/compute_digest.c Examining data/cado-0.9.5/src/file_utils.c Examining data/cado-0.9.5/src/get_user_groups.c Examining data/cado-0.9.5/src/pam_check.c Examining data/cado-0.9.5/src/read_conf.c Examining data/cado-0.9.5/src/scado.c Examining data/cado-0.9.5/src/scado_parse.c Examining data/cado-0.9.5/src/set_ambient_cap.c FINAL RESULTS: data/cado-0.9.5/src/cado_scado_check.c:121:8: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chmod(newpath, 00611) < 0) data/cado-0.9.5/src/cado.c:223:2: [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. execvp(copy_path[0] == 0 ? cmdargv[0] : copy_path, cmdargv); data/cado-0.9.5/src/cadrop.c:68:2: [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. execvp(argv[0],argv); data/cado-0.9.5/src/cado.c:91: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. char *argvsh[]={getenv("SHELL"),NULL}; data/cado-0.9.5/src/cado.c:95:9: [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. int c=getopt_long(argc, argv, OPTSTRING, long_options, NULL); data/cado-0.9.5/src/cadrop.c:44: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. char *argvsh[]={getenv("SHELL"),NULL}; data/cado-0.9.5/src/caprint.c:89:9: [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. int c=getopt_long(argc, argv, OPTSTRING, long_options, NULL); data/cado-0.9.5/src/read_conf.c:65:16: [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. s2argv_getvar=getenv; data/cado-0.9.5/src/scado.c:226:17: [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 (((editor = getenv("VISUAL")) == NULL || *editor == '\0') && data/cado-0.9.5/src/scado.c:227: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. ((editor = getenv("EDITOR")) == NULL || *editor == '\0')) { data/cado-0.9.5/src/scado.c:343:16: [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 ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir== '\0') { data/cado-0.9.5/src/scado.c:348:11: [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. int c = getopt_long(argc, argv, OPTSTRING, long_options, NULL); data/cado-0.9.5/src/cado.c:90: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 copy_path[PATH_MAX] = ""; data/cado-0.9.5/src/cado_scado_check.c:104:4: [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 newdigest[DIGESTSTRLEN + 1]; data/cado-0.9.5/src/cado_scado_check.c:180: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 scado_file[PATH_MAX]; data/cado-0.9.5/src/cado_scado_check.c:181: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 digest[DIGESTSTRLEN + 1]; data/cado-0.9.5/src/caprint.c:35: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 filename[32]; data/cado-0.9.5/src/caprint.c:42:4: [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(filename,"r"); data/cado-0.9.5/src/caprint.c:110:21: [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). capamb=get_capamb(atoi(argv[optind])); data/cado-0.9.5/src/capset_from_namelist.c:41:4: [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 xname[xnamelen]; data/cado-0.9.5/src/capset_from_namelist.c:60: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 namelist_cpy[namelistlen]; data/cado-0.9.5/src/compute_digest.c:36: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[BUFSIZE]; data/cado-0.9.5/src/compute_digest.c:37:11: [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. unsigned char binary_digest[DIGESTLEN]; data/cado-0.9.5/src/compute_digest.c:59:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(ascii_digest, "%.2x", binary_digest[i]); data/cado-0.9.5/src/compute_digest.c:67:9: [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). int fd=open(path, O_RDONLY); data/cado-0.9.5/src/compute_digest.c:81:11: [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). int infd=open(inpath, O_RDONLY); data/cado-0.9.5/src/compute_digest.c:88:10: [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). outfd = mkstemp(outtemplate); data/cado-0.9.5/src/file_utils.c:48: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[BUFSIZE]; data/cado-0.9.5/src/file_utils.c:58:11: [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). int infd=open(inpath, O_RDONLY); data/cado-0.9.5/src/file_utils.c:65:10: [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). outfd = mkstemp(outtemplate); data/cado-0.9.5/src/read_conf.c:68:4: [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(CADO_CONF, "r"); data/cado-0.9.5/src/read_conf.c:144:9: [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 ((f=open("/proc/self/exe",O_RDONLY)) >= 0) { data/cado-0.9.5/src/scado.c:130: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 scado_file[PATH_MAX]; data/cado-0.9.5/src/scado.c:144: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 tmp_file[PATH_MAX]; data/cado-0.9.5/src/scado.c:145: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 scado_file[PATH_MAX]; data/cado-0.9.5/src/scado.c:170: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 scado_file[PATH_MAX]; data/cado-0.9.5/src/scado.c:179: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(scado_file, O_RDONLY)) < 0) data/cado-0.9.5/src/scado.c:189: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 tmp_file[PATH_MAX]; data/cado-0.9.5/src/scado.c:190: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 scado_file[PATH_MAX]; data/cado-0.9.5/src/scado.c:195: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 digest_before[DIGESTSTRLEN + 1]; data/cado-0.9.5/src/scado.c:196: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 digest_after[DIGESTSTRLEN + 1]; data/cado-0.9.5/src/scado.c:213:14: [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 tmpfd=mkstemp(tmp_file); data/cado-0.9.5/src/scado_parse.c:39: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 *field[3]; data/cado-0.9.5/src/scado_parse.c:40: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 *end[3]; data/cado-0.9.5/src/scado_parse.c:83: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 caps[caplen+1]; data/cado-0.9.5/src/scado_parse.c:100: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 digest[digestlen+1]; data/cado-0.9.5/src/scado_parse.c:169: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 path[pathlen+1]; data/cado-0.9.5/src/scado_parse.c:178:4: [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 digest[DIGESTSTRLEN + 1]; data/cado-0.9.5/src/scado_parse.c:187:4: [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 digest[DIGESTSTRLEN + 1]; data/cado-0.9.5/src/scado_parse.c:216:14: [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 ((fdin = open(inpath, O_RDONLY | O_NOFOLLOW)) < 0) { data/cado-0.9.5/src/scado_parse.c:228:9: [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). fout = fopen(outpath, "w"); data/cado-0.9.5/src/scado_parse.c:253:14: [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). FILE *fin = fopen(inpath, "r"); data/cado-0.9.5/src/scado_parse.c:324: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 digest[DIGESTSTRLEN + 1]; data/cado-0.9.5/src/cado_scado_check.c:80: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). newpathlen = strlen(newpath); data/cado-0.9.5/src/cado_scado_check.c:138:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (read(gp_pipe[0], &c, sizeof(char)) > 0) data/cado-0.9.5/src/cado_scado_check.c:161:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((n=read(gc_pipe[0], newpath, newpathlen + 1)) <= 0) { data/cado-0.9.5/src/caprint.c:37: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). int target=strlen(tag); data/cado-0.9.5/src/caprint.c:46:14: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((c = getc(f)) != EOF) { data/cado-0.9.5/src/capset_from_namelist.c:40: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). int xnamelen=strlen(name)+5; data/cado-0.9.5/src/capset_from_namelist.c:59: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). size_t namelistlen = strlen(namelist) + 1; data/cado-0.9.5/src/capset_from_namelist.c:64:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(namelist_ptr, namelist, namelistlen); data/cado-0.9.5/src/compute_digest.c:44:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((n=read(infd,buf,BUFSIZE)) > 0) { data/cado-0.9.5/src/compute_digest.c:87:12: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). oldmask = umask(027); data/cado-0.9.5/src/compute_digest.c:89:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(oldmask); data/cado-0.9.5/src/file_utils.c:49:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((n = read(infd, buf, BUFSIZE)) > 0) data/cado-0.9.5/src/file_utils.c:64:12: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). oldmask = umask(077); data/cado-0.9.5/src/file_utils.c:66:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(oldmask); data/cado-0.9.5/src/scado.c:103:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(checkpipe[0], &c, 1) == 0) data/cado-0.9.5/src/scado_parse.c:84:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(caps,line->field[1],caplen); data/cado-0.9.5/src/scado_parse.c:101:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(digest,line->field[2],digestlen); data/cado-0.9.5/src/scado_parse.c:105:7: [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(digest) < DIGESTSTRLEN) data/cado-0.9.5/src/scado_parse.c:171:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(path,line->field[0],pathlen); data/cado-0.9.5/src/scado_parse.c:227:12: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). oldmask = umask(077); data/cado-0.9.5/src/scado_parse.c:229:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(oldmask); ANALYSIS SUMMARY: Hits = 74 Lines analyzed = 2140 in approximately 0.10 seconds (22249 lines/second) Physical Source Lines of Code (SLOC) = 1459 Hits@level = [0] 93 [1] 21 [2] 41 [3] 9 [4] 2 [5] 1 Hits@level+ = [0+] 167 [1+] 74 [2+] 53 [3+] 12 [4+] 3 [5+] 1 Hits/KSLOC@level+ = [0+] 114.462 [1+] 50.7197 [2+] 36.3263 [3+] 8.22481 [4+] 2.0562 [5+] 0.685401 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.