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/gradm2-3.1~201903191516/grlearn.c Examining data/gradm2-3.1~201903191516/gradm_newlearn.c Examining data/gradm2-3.1~201903191516/gradm_func.h Examining data/gradm2-3.1~201903191516/gradm_misc.c Examining data/gradm2-3.1~201903191516/gradm_fulllearn.c Examining data/gradm2-3.1~201903191516/gradm_sym.c Examining data/gradm2-3.1~201903191516/gradm_learn.c Examining data/gradm2-3.1~201903191516/gradm_pw.c Examining data/gradm2-3.1~201903191516/gradm_parse.c Examining data/gradm2-3.1~201903191516/gradm_replace.c Examining data/gradm2-3.1~201903191516/gradm_globals.c Examining data/gradm2-3.1~201903191516/gradm_human.c Examining data/gradm2-3.1~201903191516/gradm_sha256.c Examining data/gradm2-3.1~201903191516/gradm_opt.c Examining data/gradm2-3.1~201903191516/gradm_net.c Examining data/gradm2-3.1~201903191516/gradm.h Examining data/gradm2-3.1~201903191516/gradm_pam.c Examining data/gradm2-3.1~201903191516/gradm_arg.c Examining data/gradm2-3.1~201903191516/gradm_cap.c Examining data/gradm2-3.1~201903191516/gradm_pax.c Examining data/gradm2-3.1~201903191516/gradm_nest.c Examining data/gradm2-3.1~201903191516/gradm_lib.c Examining data/gradm2-3.1~201903191516/gradm_res.c Examining data/gradm2-3.1~201903191516/gradm_analyze.c Examining data/gradm2-3.1~201903191516/gradm_defs.h Examining data/gradm2-3.1~201903191516/gradm_adm.c FINAL RESULTS: data/gradm2-3.1~201903191516/gradm_adm.c:87:6: [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 (readlink(gradm_procpath, gradm_realpath, PATH_MAX - 1) < 0) data/gradm2-3.1~201903191516/gradm_opt.c:87:6: [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. readlink(proc->filename, buf, sizeof(buf) - 1); data/gradm2-3.1~201903191516/grlearn.c:136:7: [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 (readlink(procname, pathname, PATH_MAX - 1) < 0) data/gradm2-3.1~201903191516/gradm.h:57:2: [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(stderr, x ": %s\n\n", strerror(errno)); \ data/gradm2-3.1~201903191516/gradm_adm.c:467:3: [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. execl(GRLEARN_PATH, GRLEARN_PATH, logfile, (char *)NULL); data/gradm2-3.1~201903191516/gradm_adm.c:497:3: [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. execl(GRLEARN_PATH, GRLEARN_PATH, "-stop", (char *)NULL); data/gradm2-3.1~201903191516/gradm_analyze.c:30:2: [4] (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). strcpy(tmpname, filename); data/gradm2-3.1~201903191516/gradm_analyze.c:86:2: [4] (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). strcpy(tmpname, filename); data/gradm2-3.1~201903191516/gradm_arg.c:360:6: [4] (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). strcpy(pathbuf, cwd); data/gradm2-3.1~201903191516/gradm_arg.c:366:6: [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(pathbuf, optarg); data/gradm2-3.1~201903191516/gradm_fulllearn.c:550:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(current_output_file, "%s/policy", output_log); data/gradm2-3.1~201903191516/gradm_fulllearn.c:581:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(current_output_file, "%s/groups", output_log); data/gradm2-3.1~201903191516/gradm_fulllearn.c:583:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(current_output_file, "%s/groups/%s", output_log, group->rolename); data/gradm2-3.1~201903191516/gradm_fulllearn.c:601:6: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(current_output_file, "%s/users", output_log); data/gradm2-3.1~201903191516/gradm_fulllearn.c:603:6: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(current_output_file, "%s/users/%s", output_log, user->rolename); data/gradm2-3.1~201903191516/gradm_fulllearn.c:629:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(current_output_file, "%s/policy", output_log); data/gradm2-3.1~201903191516/gradm_lib.c:39:3: [4] (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). strcpy(buf, path); data/gradm2-3.1~201903191516/gradm_lib.c:50: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(buf, path + 6); data/gradm2-3.1~201903191516/gradm_lib.c:52: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(buf, path); data/gradm2-3.1~201903191516/gradm_lib.c:439:2: [4] (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). strcpy(parentdir, name); data/gradm2-3.1~201903191516/gradm_misc.c:41:3: [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. execl(GRPAM_PATH, GRPAM_PATH, rolename, (char *)NULL); data/gradm2-3.1~201903191516/gradm_misc.c:289:2: [4] (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). strcpy(p, filename); data/gradm2-3.1~201903191516/gradm_nest.c:47:2: [4] (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). strcpy(nestname, mainsubjname); data/gradm2-3.1~201903191516/gradm_nest.c:49:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(nestname + strlen(nestname), ":%s", nestednames[i]); data/gradm2-3.1~201903191516/gradm_newlearn.c:1702:6: [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(socktypeandprotos, proto->p_name); data/gradm2-3.1~201903191516/gradm_opt.c:30:2: [4] (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). strcpy(tmpproc, proc->filename); data/gradm2-3.1~201903191516/gradm_pam.c:64:8: [4] (misc) getpass: This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data (e.g., /dev/tty, stdin, stderr, etc.). In addition, some implementations overflow buffers. (CWE-676, CWE-120, CWE-20). Make the specific calls to do exactly what you want. If you continue to use it, or write your own, be sure to zero the password as soon as possible to avoid leaving the cleartext password visible in the process' address space. p = getpass(msg[i]->msg); data/gradm2-3.1~201903191516/gradm_parse.c:590:2: [4] (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). strcpy(newfilename, pwd->pw_dir); data/gradm2-3.1~201903191516/gradm_parse.c:591: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(newfilename, (filename + 5)); data/gradm2-3.1~201903191516/gradm_pw.c:31: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(GR_PW_PATH, F_OK)) != 0) { data/gradm2-3.1~201903191516/gradm_replace.c:104:2: [4] (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). strcpy(newstr, str); data/gradm2-3.1~201903191516/gradm_replace.c:105: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(newstr, replacewith); data/gradm2-3.1~201903191516/gradm_replace.c:106: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(newstr, p2 + 1); data/gradm2-3.1~201903191516/gradm_res.c:88:2: [4] (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). strcpy(p, lim); data/gradm2-3.1~201903191516/grlearn.c:204:2: [4] (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). strcpy(least->entryname, str); data/gradm2-3.1~201903191516/gradm_analyze.c:187:8: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if (!realpath(sym->obj->filename, buf)) data/gradm2-3.1~201903191516/gradm_analyze.c:354:4: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. realpath(out, target); data/gradm2-3.1~201903191516/gradm_analyze.c:509: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 ((pathstr = getenv("PATH")) == NULL) data/gradm2-3.1~201903191516/gradm_analyze.c:521:8: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if (!realpath(p, pathbuf)) data/gradm2-3.1~201903191516/gradm_analyze.c:537:7: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if (!realpath(p, pathbuf)) data/gradm2-3.1~201903191516/gradm_arg.c:263:3: [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. getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { data/gradm2-3.1~201903191516/grlearn.c:190:14: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. int start = random() % (NUM_CACHE_ENTRIES - 1); data/gradm2-3.1~201903191516/grlearn.c:290:2: [3] (random) srandom: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srandom(getpid()); data/gradm2-3.1~201903191516/gradm_adm.c:46: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(filename, O_RDONLY)) < 0) data/gradm2-3.1~201903191516/gradm_adm.c:82: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 gradm_procpath[21] = { 0 }; data/gradm2-3.1~201903191516/gradm_adm.c:101: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 gradm_realpath[PATH_MAX] = { 0 }; data/gradm2-3.1~201903191516/gradm_adm.c:473:8: [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(GR_LEARN_PIPE_PATH, O_RDONLY); data/gradm2-3.1~201903191516/gradm_analyze.c:183: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 buf[PATH_MAX]; data/gradm2-3.1~201903191516/gradm_analyze.c:371: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[PATH_MAX]; data/gradm2-3.1~201903191516/gradm_analyze.c:372: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 tmp2[PATH_MAX]; data/gradm2-3.1~201903191516/gradm_analyze.c:430: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[PATH_MAX]; data/gradm2-3.1~201903191516/gradm_analyze.c:436:18: [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 ((liloconf = fopen("/etc/lilo.conf", "r")) == NULL) data/gradm2-3.1~201903191516/gradm_analyze.c:469: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[PATH_MAX]; data/gradm2-3.1~201903191516/gradm_analyze.c:474:16: [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 ((ldconf = fopen("/etc/ld.so.conf", "r")) == NULL) data/gradm2-3.1~201903191516/gradm_analyze.c:504: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 pathbuf[PATH_MAX]; data/gradm2-3.1~201903191516/gradm_arg.c:193:15: [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). learnfile = fopen(learn_log, "r"); data/gradm2-3.1~201903191516/gradm_arg.c:223: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 cwd[PATH_MAX]; data/gradm2-3.1~201903191516/gradm_arg.c:333:22: [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). entry.segv_uid = atoi(optarg); data/gradm2-3.1~201903191516/gradm_arg.c:356:5: [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 pathbuf[PATH_MAX]; data/gradm2-3.1~201903191516/gradm_arg.c:500:15: [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). stream = fopen(output_log, "w"); data/gradm2-3.1~201903191516/gradm_arg.c:502:15: [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). stream = fopen(output_log, "a"); data/gradm2-3.1~201903191516/gradm_defs.h:521: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 rolename[GR_SPROLE_LEN]; data/gradm2-3.1~201903191516/gradm_defs.h:522: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 passwd[GR_PW_LEN]; data/gradm2-3.1~201903191516/gradm_defs.h:523: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 sum[GR_SHA_SUM_SIZE]; data/gradm2-3.1~201903191516/gradm_defs.h:524: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 salt[GR_SALT_SIZE]; data/gradm2-3.1~201903191516/gradm_defs.h:611: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 salt[GR_SALT_SIZE]; data/gradm2-3.1~201903191516/gradm_defs.h:612: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 sum[GR_SHA_SUM_SIZE]; data/gradm2-3.1~201903191516/gradm_defs.h:617: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 pw[GR_PW_LEN]; data/gradm2-3.1~201903191516/gradm_defs.h:618: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 salt[GR_SALT_SIZE]; data/gradm2-3.1~201903191516/gradm_defs.h:619: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 sum[GR_SHA_SUM_SIZE]; data/gradm2-3.1~201903191516/gradm_defs.h:620: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 sp_role[GR_SPROLE_LEN]; data/gradm2-3.1~201903191516/gradm_defs.h:635:14: [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. extern const char *rlim_table[GR_NLIMITS]; data/gradm2-3.1~201903191516/gradm_fulllearn.c:551: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). stream = fopen(current_output_file, "w"); data/gradm2-3.1~201903191516/gradm_fulllearn.c:584: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). stream = fopen(current_output_file, "w"); data/gradm2-3.1~201903191516/gradm_fulllearn.c:604:15: [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). stream = fopen(current_output_file, "w"); data/gradm2-3.1~201903191516/gradm_fulllearn.c:630:18: [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). policystream = fopen(current_output_file, "a"); data/gradm2-3.1~201903191516/gradm_learn.c:270: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 rolemode[17]; data/gradm2-3.1~201903191516/gradm_lib.c:43: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(buf, "/usr"); data/gradm2-3.1~201903191516/gradm_lib.c:49:3: [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(buf, "/bin/"); data/gradm2-3.1~201903191516/gradm_lib.c:256: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(hash, newhash, sizeof(struct gr_hash_struct)); data/gradm2-3.1~201903191516/gradm_lib.c:379: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). FILE *f = fopen("/proc/mounts", "r"); data/gradm2-3.1~201903191516/gradm_lib.c:380: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[4096] = { }; data/gradm2-3.1~201903191516/gradm_lib.c:440: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(parentdir, "/.."); data/gradm2-3.1~201903191516/gradm_misc.c:63:21: [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). grlearn_configin = fopen(GR_LEARN_CONFIG_PATH, "r"); data/gradm2-3.1~201903191516/gradm_misc.c:87:17: [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 ((aclfile = fopen(filename, "r")) == NULL) { data/gradm2-3.1~201903191516/gradm_misc.c:101: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(GRDEV_PATH, O_WRONLY)) < 0) { data/gradm2-3.1~201903191516/gradm_misc.c:191: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(GRDEV_PATH, O_WRONLY)) < 0) { data/gradm2-3.1~201903191516/gradm_net.c:192: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(&(acl_tmp->addr), *p, sizeof(acl_tmp->addr)); data/gradm2-3.1~201903191516/gradm_net.c:238: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(p->proto, acl_tmp->proto, sizeof (acl_tmp->proto)); data/gradm2-3.1~201903191516/gradm_net.c:291: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). int pro = atoi(name+strlen("proto:")); data/gradm2-3.1~201903191516/gradm_newlearn.c:1425: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 modes[33]; data/gradm2-3.1~201903191516/gradm_newlearn.c:1643: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 ipandtype[64] = {0}; data/gradm2-3.1~201903191516/gradm_newlearn.c:1644: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 socktypeandprotos[4096] = {0}; data/gradm2-3.1~201903191516/gradm_newlearn.c:1671:3: [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(ipandtype, "\tconnect %u.%u.%u.%u/%u", ip[0], ip[1], ip[2], ip[3], netmask); data/gradm2-3.1~201903191516/gradm_newlearn.c:1673:3: [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(ipandtype, "\tbind %u.%u.%u.%u/%u", ip[0], ip[1], ip[2], ip[3], netmask); data/gradm2-3.1~201903191516/gradm_newlearn.c:1679:5: [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(socktypeandprotos, " raw_sock"); data/gradm2-3.1~201903191516/gradm_newlearn.c:1682:5: [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(socktypeandprotos, " dgram"); data/gradm2-3.1~201903191516/gradm_newlearn.c:1685:5: [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(socktypeandprotos, " stream"); data/gradm2-3.1~201903191516/gradm_newlearn.c:1688:5: [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(socktypeandprotos, " rdm"); data/gradm2-3.1~201903191516/gradm_newlearn.c:1697:5: [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(socktypeandprotos, " raw_proto"); data/gradm2-3.1~201903191516/gradm_newlearn.c:1704:6: [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(socktypeandprotos+strlen(socktypeandprotos), "proto:%d", i); data/gradm2-3.1~201903191516/gradm_newlearn.c:1966: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(ip_node, &ip, sizeof(ip)); data/gradm2-3.1~201903191516/gradm_opt.c:85:5: [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[PATH_MAX] = {0}; data/gradm2-3.1~201903191516/gradm_pam.c:114: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(GRDEV_PATH, O_WRONLY)) < 0) { data/gradm2-3.1~201903191516/gradm_parse.c:334: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(tmp, subject, sizeof(struct proc_acl)); data/gradm2-3.1~201903191516/gradm_parse.c:1108: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(grarg->sprole_pws[i].salt, entry.salt, data/gradm2-3.1~201903191516/gradm_parse.c:1110: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(grarg->sprole_pws[i].sum, entry.sum, data/gradm2-3.1~201903191516/gradm_parse.c:1187: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(&retarg->role_db, role_db, sizeof (struct user_acl_role_db)); data/gradm2-3.1~201903191516/gradm_pw.c:29: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 total[GR_SPROLE_LEN + GR_SHA_SUM_SIZE + GR_SALT_SIZE]; data/gradm2-3.1~201903191516/gradm_pw.c:33:8: [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). open(GR_PW_PATH, O_EXCL | O_CREAT, data/gradm2-3.1~201903191516/gradm_pw.c:42: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(GR_PW_PATH, O_RDWR)) < 0) { data/gradm2-3.1~201903191516/gradm_pw.c:151: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("/dev/urandom", O_RDONLY)) < 0) { data/gradm2-3.1~201903191516/gradm_pw.c:170: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 cmp[GR_SPROLE_LEN]; data/gradm2-3.1~201903191516/gradm_pw.c:171: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 total[GR_SPROLE_LEN + GR_SHA_SUM_SIZE + GR_SALT_SIZE]; data/gradm2-3.1~201903191516/gradm_pw.c:175:7: [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(GR_PW_PATH, O_RDONLY); data/gradm2-3.1~201903191516/gradm_pw.c:198: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(salt, total + GR_SPROLE_LEN, GR_SALT_SIZE); data/gradm2-3.1~201903191516/gradm_pw.c:199: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(pass, total + GR_SPROLE_LEN + GR_SALT_SIZE, GR_SHA_SUM_SIZE); data/gradm2-3.1~201903191516/gradm_res.c:23: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. const char *rlim_table[GR_NLIMITS]; data/gradm2-3.1~201903191516/gradm_res.c:83:10: [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). return atol(lim); data/gradm2-3.1~201903191516/gradm_res.c:100:8: [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). res = atol(p); data/gradm2-3.1~201903191516/gradm_res.c:168: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(&(subject->res[name_to_res(name)]), &lim, sizeof (lim)); data/gradm2-3.1~201903191516/gradm_sha256.c:217: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(&C->buf[index], input, partLen); data/gradm2-3.1~201903191516/gradm_sha256.c:228: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(&C->buf[index], &input[i], inputLen - i); data/gradm2-3.1~201903191516/gradm_sym.c:201: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(v, var, sizeof(struct var_object)); data/gradm2-3.1~201903191516/gradm_sym.c:227: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(&var.net_obj.ip, ip, sizeof(struct ip_acl)); data/gradm2-3.1~201903191516/grlearn.c:42:28: [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). grlearn_configin = fopen(GR_LEARN_CONFIG_PATH, "r"); data/gradm2-3.1~201903191516/grlearn.c:89:7: [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(GR_LEARN_PID_PATH, O_RDONLY); data/gradm2-3.1~201903191516/grlearn.c:111: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 pathname[PATH_MAX] = {0}; data/gradm2-3.1~201903191516/grlearn.c:112: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 procname[64] = {0}; data/gradm2-3.1~201903191516/grlearn.c:122:8: [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(GR_LEARN_PID_PATH, O_RDONLY); data/gradm2-3.1~201903191516/grlearn.c:145:7: [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(GR_LEARN_PID_PATH, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); data/gradm2-3.1~201903191516/grlearn.c:315:7: [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(GRDEV_PATH, O_RDONLY); data/gradm2-3.1~201903191516/grlearn.c:323:8: [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(argv[1], O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR); data/gradm2-3.1~201903191516/grlearn.c:343: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). pipefd = open(GR_LEARN_PIPE_PATH, O_WRONLY); data/gradm2-3.1~201903191516/grlearn.c:354: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). pipefd = open(GR_LEARN_PIPE_PATH, O_WRONLY); data/gradm2-3.1~201903191516/grlearn.c:376:7: [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(writep, p, len); data/gradm2-3.1~201903191516/gradm_adm.c:49:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((read(fd, &header_elf64, sizeof (header_elf64)) != sizeof (header_elf64))) data/gradm2-3.1~201903191516/gradm_adm.c:127:7: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (getchar() != 'y') data/gradm2-3.1~201903191516/gradm_adm.c:480:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). (void)read(fd, &b, 1); data/gradm2-3.1~201903191516/gradm_analyze.c:28: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). char *tmpname = (char *)alloca(strlen(filename) + 1); data/gradm2-3.1~201903191516/gradm_analyze.c:84: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). char *tmpname = (char *)alloca(strlen(filename) + 1); data/gradm2-3.1~201903191516/gradm_analyze.c:346:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(out, filename, PATH_MAX); data/gradm2-3.1~201903191516/gradm_analyze.c:444: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). if (buf[strlen(buf) - 1] == '\n') data/gradm2-3.1~201903191516/gradm_analyze.c:445: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). buf[strlen(buf) - 1] = '\0'; data/gradm2-3.1~201903191516/gradm_analyze.c:482: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). if (buf[strlen(buf) - 1] == '\n') data/gradm2-3.1~201903191516/gradm_analyze.c:483: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). buf[strlen(buf) - 1] = '\0'; data/gradm2-3.1~201903191516/gradm_arg.c:326: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). || (strlen(optarg) < 1)) data/gradm2-3.1~201903191516/gradm_arg.c:361: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). if (strlen(optarg) + strlen(pathbuf) + 2 > PATH_MAX) { data/gradm2-3.1~201903191516/gradm_arg.c:361:27: [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) + strlen(pathbuf) + 2 > PATH_MAX) { data/gradm2-3.1~201903191516/gradm_arg.c:365:6: [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(pathbuf, "/"); data/gradm2-3.1~201903191516/gradm_arg.c:384:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy((char *)entry.rolename, argv[2], GR_SPROLE_LEN); data/gradm2-3.1~201903191516/gradm_arg.c:400:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy((char *)entry.rolename, argv[2], GR_SPROLE_LEN); data/gradm2-3.1~201903191516/gradm_arg.c:412:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy((char *)entry.rolename, argv[2], GR_SPROLE_LEN); data/gradm2-3.1~201903191516/gradm_arg.c:424:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy((char *)entry.rolename, argv[2], GR_SPROLE_LEN); data/gradm2-3.1~201903191516/gradm_defs.h:395:13: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). u_int16_t umask; data/gradm2-3.1~201903191516/gradm_fulllearn.c:542:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(0077); data/gradm2-3.1~201903191516/gradm_fulllearn.c:549:40: [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). current_output_file = (char *)alloca(strlen(output_log) + 16384); data/gradm2-3.1~201903191516/gradm_func.h:202:54: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). void set_role_umask(struct role_acl *role, u_int16_t umask); data/gradm2-3.1~201903191516/gradm_lib.c:34:21: [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). unsigned int len = strlen(path); data/gradm2-3.1~201903191516/gradm_lib.c:36: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). char *buf = gr_alloc(len + strlen("/usr") + 1); data/gradm2-3.1~201903191516/gradm_lib.c:434: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). parentdir = gr_alloc(strlen(name) + 4); data/gradm2-3.1~201903191516/gradm_misc.c:286:27: [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 ((p = (char *) calloc(strlen(filename) + 1, sizeof (char))) == NULL) data/gradm2-3.1~201903191516/gradm_misc.c:301: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(*parent_dirent) <= 1) || (strlen(filename) <= 1)) data/gradm2-3.1~201903191516/gradm_misc.c:301:40: [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(*parent_dirent) <= 1) || (strlen(filename) <= 1)) data/gradm2-3.1~201903191516/gradm_misc.c:304: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). for (i = strlen(*parent_dirent) - 1; i >= 0; i--) { data/gradm2-3.1~201903191516/gradm_nest.c:42: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). namelen += strlen(mainsubjname); data/gradm2-3.1~201903191516/gradm_nest.c:44:14: [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). namelen += strlen(nestednames[i]) + 1; data/gradm2-3.1~201903191516/gradm_nest.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). sprintf(nestname + strlen(nestname), ":%s", nestednames[i]); data/gradm2-3.1~201903191516/gradm_nest.c:88: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). namelen = strlen(nestednames[i-1]); data/gradm2-3.1~201903191516/gradm_net.c:290: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). } else if (!strncmp(name, "proto:", strlen("proto:"))) { data/gradm2-3.1~201903191516/gradm_net.c:291: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). int pro = atoi(name+strlen("proto:")); data/gradm2-3.1~201903191516/gradm_newlearn.c:55: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). len = strlen(*tmp); data/gradm2-3.1~201903191516/gradm_newlearn.c:80: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). len = strlen(*tmp); data/gradm2-3.1~201903191516/gradm_newlearn.c:107: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). len = strlen(*tmp); data/gradm2-3.1~201903191516/gradm_newlearn.c:202: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). baselen = strlen(basename); data/gradm2-3.1~201903191516/gradm_newlearn.c:595: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). filelen = strlen(filename); data/gradm2-3.1~201903191516/gradm_newlearn.c:600: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). baselen = strlen(base->filename); data/gradm2-3.1~201903191516/gradm_newlearn.c:1059: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). baselen = strlen((*base)->filename); data/gradm2-3.1~201903191516/gradm_newlearn.c:1111: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). alen = strlen(filelist->filename); data/gradm2-3.1~201903191516/gradm_newlearn.c:1112: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). blen = strlen(filename); data/gradm2-3.1~201903191516/gradm_newlearn.c:1176:51: [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). node = find_insert_file(base, replace->filename, strlen(replace->filename)); data/gradm2-3.1~201903191516/gradm_newlearn.c:1199:42: [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). node = find_insert_file(base, filename, strlen(filename)); data/gradm2-3.1~201903191516/gradm_newlearn.c:1250:26: [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). unsigned int node_len = strlen(node->filename); data/gradm2-3.1~201903191516/gradm_newlearn.c:1328: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). len = strlen(*tmp); data/gradm2-3.1~201903191516/gradm_newlearn.c:1393: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). parentlen = strlen(node->parent->filename); data/gradm2-3.1~201903191516/gradm_newlearn.c:1394: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). ourlen = strlen(node->filename); data/gradm2-3.1~201903191516/gradm_newlearn.c:1569: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). i = strlen(node->filename); data/gradm2-3.1~201903191516/gradm_newlearn.c:1700:5: [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(socktypeandprotos, " "); data/gradm2-3.1~201903191516/gradm_newlearn.c:1704:32: [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). sprintf(socktypeandprotos+strlen(socktypeandprotos), "proto:%d", i); data/gradm2-3.1~201903191516/gradm_opt.c:29:27: [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). tmpproc = (char *)alloca(strlen(proc->filename) + 1); data/gradm2-3.1~201903191516/gradm_pam.c:69: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). memset(p, 0, strlen(p)); data/gradm2-3.1~201903191516/gradm_pam.c:82:34: [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(response[x].resp, 0, strlen(response[x].resp)); data/gradm2-3.1~201903191516/gradm_parse.c:26:54: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). void set_role_umask(struct role_acl *role, u_int16_t umask) data/gradm2-3.1~201903191516/gradm_parse.c:28:16: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). role->umask = umask; data/gradm2-3.1~201903191516/gradm_parse.c:33:26: [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). unsigned int file_len = strlen(filename); data/gradm2-3.1~201903191516/gradm_parse.c:581: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). newlen = strlen(pwd->pw_dir) + strlen(filename) - 5 + 1; data/gradm2-3.1~201903191516/gradm_parse.c:581: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). newlen = strlen(pwd->pw_dir) + strlen(filename) - 5 + 1; data/gradm2-3.1~201903191516/gradm_parse.c:785: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). int len = strlen(mode) - 1; data/gradm2-3.1~201903191516/gradm_parse.c:880: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). for (i = 0; i < strlen(mode); i++) { data/gradm2-3.1~201903191516/gradm_parse.c:961: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). for (i = 0; i < strlen(mode); i++) { data/gradm2-3.1~201903191516/gradm_parse.c:1095:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy((char *)entry.rolename, rtmp->rolename, GR_SPROLE_LEN); data/gradm2-3.1~201903191516/gradm_parse.c:1190:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy((char *)retarg->pw, (char *)entry->passwd, GR_PW_LEN - 1); data/gradm2-3.1~201903191516/gradm_parse.c:1192:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy((char *)retarg->sp_role, (char *)entry->rolename, GR_SPROLE_LEN); data/gradm2-3.1~201903191516/gradm_pw.c:47:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((len = read(fd, total, sizeof (total))) == sizeof (total)) { data/gradm2-3.1~201903191516/gradm_pw.c:108:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((read(STDIN_FILENO, entry->passwd, GR_PW_LEN - 1)) < 0) { data/gradm2-3.1~201903191516/gradm_pw.c:124: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). entry->passwd[strlen((char *)entry->passwd) - 1] = '\0'; data/gradm2-3.1~201903191516/gradm_pw.c:126: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((char *)entry->passwd) < 6) && mode == 1) { data/gradm2-3.1~201903191516/gradm_pw.c:156:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(fd, entry->salt, GR_SALT_SIZE) != GR_SALT_SIZE) { data/gradm2-3.1~201903191516/gradm_pw.c:182:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((len = read(fd, total, sizeof (total))) == sizeof (total)) { data/gradm2-3.1~201903191516/gradm_replace.c:102: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). newlen = strlen(str) + strlen(p2 + 1) + strlen(replacewith); data/gradm2-3.1~201903191516/gradm_replace.c:102:25: [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). newlen = strlen(str) + strlen(p2 + 1) + strlen(replacewith); data/gradm2-3.1~201903191516/gradm_replace.c:102:42: [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). newlen = strlen(str) + strlen(p2 + 1) + strlen(replacewith); data/gradm2-3.1~201903191516/gradm_res.c:77:21: [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). unsigned int len = strlen(lim); data/gradm2-3.1~201903191516/gradm_sha256.c:287:44: [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). pos = (char *)memchr(entry->passwd, '\n', strlen((char *)entry->passwd)); data/gradm2-3.1~201903191516/gradm_sha256.c:293:40: [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). SHA256Update(&context, entry->passwd, strlen((char *)entry->passwd)); data/gradm2-3.1~201903191516/grlearn.c:67:34: [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). always_reduce_paths[size].len = strlen(str); data/gradm2-3.1~201903191516/grlearn.c:94:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ignore_ret = read(fd, &learn_pid, sizeof(learn_pid)); data/gradm2-3.1~201903191516/grlearn.c:131:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ignore_ret = read(fd, &learn_pid, sizeof(learn_pid)); data/gradm2-3.1~201903191516/grlearn.c:367:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). retval = read(fd, buf, LEARN_BUFFER_SIZE - 1); data/gradm2-3.1~201903191516/grlearn.c:372: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). len = strlen(p); ANALYSIS SUMMARY: Hits = 220 Lines analyzed = 11273 in approximately 0.35 seconds (31909 lines/second) Physical Source Lines of Code (SLOC) = 8892 Hits@level = [0] 309 [1] 84 [2] 93 [3] 8 [4] 32 [5] 3 Hits@level+ = [0+] 529 [1+] 220 [2+] 136 [3+] 43 [4+] 35 [5+] 3 Hits/KSLOC@level+ = [0+] 59.4917 [1+] 24.7413 [2+] 15.2946 [3+] 4.83581 [4+] 3.93612 [5+] 0.337382 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.