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/jailkit-2.21/src/jk_chrootlaunch.c Examining data/jailkit-2.21/src/passwdparsertester.c Examining data/jailkit-2.21/src/iniparser.c Examining data/jailkit-2.21/src/iniparsertester.c Examining data/jailkit-2.21/src/jk_lsh.c Examining data/jailkit-2.21/src/passwdparser.c Examining data/jailkit-2.21/src/wordexp.h Examining data/jailkit-2.21/src/jk_lib.h Examining data/jailkit-2.21/src/iniparser.h Examining data/jailkit-2.21/src/jk_socketd.c Examining data/jailkit-2.21/src/jk_uchroot.c Examining data/jailkit-2.21/src/jk_lib.c Examining data/jailkit-2.21/src/passwdparser.h Examining data/jailkit-2.21/src/jk_chrootsh.c Examining data/jailkit-2.21/src/utils.h Examining data/jailkit-2.21/src/wordexp.c Examining data/jailkit-2.21/src/utils.c Examining data/jailkit-2.21/src/jk_procmailwrapper.c FINAL RESULTS: data/jailkit-2.21/src/jk_socketd.c:125:18: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (ret != 0 || chmod(sl->inpath, 0666)) { data/jailkit-2.21/src/jk_chrootlaunch.c:144:12: [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). tmpstr = strcat(strcat(tmpstr, jail), exec); data/jailkit-2.21/src/jk_chrootlaunch.c:144:19: [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). tmpstr = strcat(strcat(tmpstr, jail), exec); data/jailkit-2.21/src/jk_chrootlaunch.c:173:2: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(PACKAGE" "VERSION"\nUsage: "PROGRAMNAME" -j jaildir [-u user] [-g group] [-p pidfile] -x executable -- [executable options]\n"); data/jailkit-2.21/src/jk_chrootlaunch.c:180:2: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(PROGRAMNAME" logs all errors to syslog, for diagnostics check your logfiles\n"); data/jailkit-2.21/src/jk_chrootlaunch.c:285:2: [4] (shell) execv: 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. execv(exec, newargv); data/jailkit-2.21/src/jk_chrootsh.c:64:19: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define DEBUG_MSG printf data/jailkit-2.21/src/jk_chrootsh.c:286:14: [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). groupsec = strcat(strcpy(malloc0(strlen(gr->gr_name)+7), "group "), gr->gr_name); data/jailkit-2.21/src/jk_chrootsh.c:570:2: [4] (shell) execv: 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. execv(shell, newargv); data/jailkit-2.21/src/jk_lib.c:79:13: [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). retval = strcat(retval, delimiter); data/jailkit-2.21/src/jk_lib.c:81:12: [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). retval = strcat(retval, arr[i]); data/jailkit-2.21/src/jk_lib.c:94:17: [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). return strcat(strcat(malloc0((len+2)*sizeof(char)), src), "/"); data/jailkit-2.21/src/jk_lib.c:152:42: [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). if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "dev/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:153:42: [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). if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "etc/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:154:42: [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). if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "lib/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:155:42: [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). if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "usr/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:156:42: [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). if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "bin/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:157:42: [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). if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "sbin/"), 0, 0)&~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.h:39:19: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define DEBUG_MSG printf data/jailkit-2.21/src/jk_lib.h:46:28: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. #define DEBUG_LOG(args...) syslog(LOG_DEBUG, args) data/jailkit-2.21/src/jk_lsh.c:172:2: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_INFO, PROGRAMNAME" version "VERSION", started"); data/jailkit-2.21/src/jk_lsh.c:222:13: [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). groupsec = strcat(strcpy(malloc0(strlen(gr->gr_name)+7), "group "), gr->gr_name); data/jailkit-2.21/src/jk_lsh.c:230:3: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_ERR, "did neither find a section '%s', nor 'group %s' nor 'DEFAULT' in configfile "CONFIGFILE, pw->pw_name, gr->gr_name); data/jailkit-2.21/src/jk_lsh.c:283:3: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_ERR, "WARNING: user %s (%u) tried to run '%s', which is not allowed according to "CONFIGFILE, pw->pw_name, getuid(),logstring); data/jailkit-2.21/src/jk_procmailwrapper.c:264:3: [4] (shell) execv: 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. execv(PROCMAILPATH, newargv); data/jailkit-2.21/src/jk_socketd.c:234:2: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(PROGRAMNAME" version "VERSION", usage:\n\n"); data/jailkit-2.21/src/jk_socketd.c:353:4: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_CRIT, "version "VERSION", abort, could not parse configfile "CONFIGFILE); data/jailkit-2.21/src/jk_socketd.c:447:4: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_ERR, "failed to chroot to "INIPREFIX); data/jailkit-2.21/src/jk_socketd.c:448:18: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. if (nodetach) printf("failed to chroot to "INIPREFIX); data/jailkit-2.21/src/jk_uchroot.c:67:19: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define DEBUG_MSG printf data/jailkit-2.21/src/jk_uchroot.c:85:2: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(PACKAGE" "VERSION"\nUsage: "PROGRAMNAME" -j jaildir -x executable -- [executable options]\n"); data/jailkit-2.21/src/jk_uchroot.c:89:2: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(PROGRAMNAME" logs all errors to syslog, for diagnostics check your logfiles\n"); data/jailkit-2.21/src/jk_uchroot.c:263:14: [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). groupsec = strcat(strcpy(malloc0(strlen(gr->gr_name)+7), "group "), gr->gr_name); data/jailkit-2.21/src/jk_uchroot.c:291:4: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_ERR,"abort, no relevant section for user %s (%u) or group %s (%u) or DEFAULT found in "CONFIGFILE, pw->pw_name,getuid(),gr->gr_name,getgid()); data/jailkit-2.21/src/jk_uchroot.c:297:3: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_ERR,"abort, no config file "CONFIGFILE); data/jailkit-2.21/src/jk_uchroot.c:445:2: [4] (shell) execv: 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. execv(executable, newargv); data/jailkit-2.21/src/passwdparser.c:45:19: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define DEBUG_MSG printf data/jailkit-2.21/src/utils.c:80: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(dest, src); data/jailkit-2.21/src/jk_chrootlaunch.c:206: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. c = getopt_long(argc, argv, "j:p:u:g:x:hv",long_options, &option_index); data/jailkit-2.21/src/jk_chrootlaunch.c:272:6: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if (chroot(jail)) { data/jailkit-2.21/src/jk_chrootsh.c:231:8: [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. tmp = getenv("USER"); data/jailkit-2.21/src/jk_chrootsh.c:422:6: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if (chroot(jaildir)) { data/jailkit-2.21/src/jk_lsh.c:175:8: [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. tmp = getenv("USER"); data/jailkit-2.21/src/jk_procmailwrapper.c:190:6: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if (chroot(jaildir)) { data/jailkit-2.21/src/jk_socketd.c:284: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. c = getopt_long(argc, argv, "p:nh",long_options, &option_index); data/jailkit-2.21/src/jk_socketd.c:446:27: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if (!(chdir(path)==0 && chroot(path)==0)) { data/jailkit-2.21/src/jk_uchroot.c:163:8: [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. tmp = getenv("USER"); data/jailkit-2.21/src/jk_uchroot.c:209: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. c = getopt_long(argc, argv, "j:x:hv",long_options, &option_index); data/jailkit-2.21/src/jk_uchroot.c:358:6: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if (chroot(jail)) { data/jailkit-2.21/src/wordexp.c:1232:11: [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. value = getenv(env); data/jailkit-2.21/src/wordexp.c:1938:8: [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. ifs = getenv("IFS"); data/jailkit-2.21/src/iniparser.c:49:8: [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). tmp = fopen(filename, "r"); data/jailkit-2.21/src/iniparser.c:107:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer[256], *found; data/jailkit-2.21/src/iniparser.c:225:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char data[25]; data/jailkit-2.21/src/iniparser.c:237:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char data[25]; data/jailkit-2.21/src/iniparser.c:250:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char data[25]; data/jailkit-2.21/src/iniparsertester.c:14: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 buffer[1024]; data/jailkit-2.21/src/jk_chrootlaunch.c:247: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). FILE *pidfilefd = fopen(pidfile, "w"); data/jailkit-2.21/src/jk_chrootsh.c:286:21: [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. groupsec = strcat(strcpy(malloc0(strlen(gr->gr_name)+7), "group "), gr->gr_name); data/jailkit-2.21/src/jk_chrootsh.c:340: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("/dev/null", O_RDWR); data/jailkit-2.21/src/jk_chrootsh.c:380: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 test[1024]; data/jailkit-2.21/src/jk_lib.c:152:35: [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. if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "dev/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:153:35: [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. if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "etc/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:154:35: [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. if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "lib/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:155:35: [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. if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "usr/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:156:35: [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. if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "bin/"), 0, 0) &~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lib.c:157:35: [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. if (retval == 1 && (testsafepath(strcat(strcpy(tmp,path_w_slash), "sbin/"), 0, 0)&~TESTPATH_NOREGPATH)!=0) retval = 0; data/jailkit-2.21/src/jk_lsh.c:94:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer[1024]; data/jailkit-2.21/src/jk_lsh.c:157: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 *new, buffer[1024], *tmp=NULL, *user=NULL; data/jailkit-2.21/src/jk_lsh.c:222:20: [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. groupsec = strcat(strcpy(malloc0(strlen(gr->gr_name)+7), "group "), gr->gr_name); data/jailkit-2.21/src/jk_socketd.c:161: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[BUFSIZE]; data/jailkit-2.21/src/jk_socketd.c:303:15: [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). m_base = atoi(optarg); data/jailkit-2.21/src/jk_socketd.c:309:15: [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). m_peak = atoi(optarg); data/jailkit-2.21/src/jk_socketd.c:312:15: [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). m_peak = atoi(optarg); data/jailkit-2.21/src/jk_socketd.c:350: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[1024], *tmp; data/jailkit-2.21/src/jk_socketd.c:428:27: [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 (pidfile) pidfilefd = fopen(pidfile, "w"); data/jailkit-2.21/src/jk_socketd.c:470: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 buf[32]; data/jailkit-2.21/src/jk_uchroot.c:263:21: [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. groupsec = strcat(strcpy(malloc0(strlen(gr->gr_name)+7), "group "), gr->gr_name); data/jailkit-2.21/src/jk_uchroot.c:314: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("/dev/null", O_RDWR); data/jailkit-2.21/src/jk_uchroot.c:347: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 test[1024]; data/jailkit-2.21/src/passwdparser.c:76:12: [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). retval = atoi(tmp); data/jailkit-2.21/src/passwdparser.c:86: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[BLOCKSIZE+1]; data/jailkit-2.21/src/passwdparser.c:92:7: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fp = fopen(filename,"r"); data/jailkit-2.21/src/passwdparser.c:155: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 find[11], *line; data/jailkit-2.21/src/utils.c:55: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(ret, s, n); data/jailkit-2.21/src/utils.c:73: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(dest,src,n); data/jailkit-2.21/src/wordexp.c:640: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 result[21]; /* 21 = ceil(log10(2^64)) + 1 */ data/jailkit-2.21/src/wordexp.c:681: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 result[21]; /* 21 = ceil(log10(2^64)) + 1 */ data/jailkit-2.21/src/wordexp.c:752:9: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. const char *args[4] = { _PATH_BSHELL, "-c", comm, NULL }; data/jailkit-2.21/src/wordexp.c:762: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). fd = open(_PATH_DEVNULL, O_WRONLY); data/jailkit-2.21/src/wordexp.c:985:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer[21]; data/jailkit-2.21/src/wordexp.c:1154:11: [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 n = atoi(env); data/jailkit-2.21/src/wordexp.c:1591: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 param_length[21]; data/jailkit-2.21/src/wordexp.c:1904: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 ifs_white[4]; data/jailkit-2.21/src/wordexp.c:1942:9: [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. ifs = strcpy(ifs_white, " \t\n"); data/jailkit-2.21/src/iniparser.c:79:6: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch=fgetc(ip->fd); data/jailkit-2.21/src/iniparser.c:132:6: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch=fgetc(ip->fd); data/jailkit-2.21/src/iniparsertester.c:17: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). nextitempos = iniparser_get_position(parser) - strlen("nextitem") - 2; data/jailkit-2.21/src/jk_chrootlaunch.c:138: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). if (strncmp(jail,exec,strlen(jail))==0) { data/jailkit-2.21/src/jk_chrootlaunch.c:143: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). tmpstr = malloc0((strlen(exec)+strlen(jail)+1)*sizeof(char)); data/jailkit-2.21/src/jk_chrootlaunch.c:143: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). tmpstr = malloc0((strlen(exec)+strlen(jail)+1)*sizeof(char)); data/jailkit-2.21/src/jk_chrootlaunch.c:167: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). retval = strdup(&tmpstr[strlen(jail)]); data/jailkit-2.21/src/jk_chrootsh.c:117: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(*tmp)==needlelen && strncmp(*tmp, needle, needlelen)==0) return 1; data/jailkit-2.21/src/jk_chrootsh.c:232: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). if (tmp && strlen(tmp)) { data/jailkit-2.21/src/jk_chrootsh.c:244: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). if (!pw->pw_name || strlen(pw->pw_name)==0) { data/jailkit-2.21/src/jk_chrootsh.c:286:36: [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). groupsec = strcat(strcpy(malloc0(strlen(gr->gr_name)+7), "group "), gr->gr_name); data/jailkit-2.21/src/jk_chrootsh.c:296:56: [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 pos = iniparser_get_position(parser) - strlen(section) - 2; data/jailkit-2.21/src/jk_chrootsh.c:361: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). if (!pw->pw_dir || strlen(pw->pw_dir) ==0) { data/jailkit-2.21/src/jk_lib.c:65: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). int count=0,i=0,reqsize=1, delsize=strlen(delimiter); data/jailkit-2.21/src/jk_lib.c:71: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). reqsize += delsize + strlen(*tmp); data/jailkit-2.21/src/jk_lib.c:90: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). len = strlen(src); data/jailkit-2.21/src/jk_lib.c:94:10: [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. return strcat(strcat(malloc0((len+2)*sizeof(char)), src), "/"); data/jailkit-2.21/src/jk_lib.c:151:16: [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). tmp = malloc0(strlen(path_w_slash)+6); data/jailkit-2.21/src/jk_lib.c:167: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). d1len = strlen(dir1); data/jailkit-2.21/src/jk_lib.c:168: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). d2len = strlen(dir2); data/jailkit-2.21/src/jk_lib.c:184: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). int i=strlen(oldhomedir); data/jailkit-2.21/src/jk_lib.c:202: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). int numstartspaces=0, endofcontent=strlen(string)-1; data/jailkit-2.21/src/jk_lib.c:240: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(arr[cur])==0) { data/jailkit-2.21/src/jk_lsh.c:122: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). int elen = strlen(executable); data/jailkit-2.21/src/jk_lsh.c:125: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). int tlen = strlen(*path); data/jailkit-2.21/src/jk_lsh.c:128:14: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). newpath = strncpy(newpath, *path, tlen); data/jailkit-2.21/src/jk_lsh.c:130:15: [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. newpath = strcat(newpath, "/"); data/jailkit-2.21/src/jk_lsh.c:133:14: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. newpath = strncat(newpath, executable, elen); data/jailkit-2.21/src/jk_lsh.c:176: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). if (tmp && strlen(tmp)) { data/jailkit-2.21/src/jk_lsh.c:222:35: [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). groupsec = strcat(strcpy(malloc0(strlen(gr->gr_name)+7), "group "), gr->gr_name); data/jailkit-2.21/src/jk_lsh.c:233:49: [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). section_pos = iniparser_get_position(parser) - strlen(section) - 2; data/jailkit-2.21/src/jk_lsh.c:241:14: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). oldumask = umask(umaskval); data/jailkit-2.21/src/jk_procmailwrapper.c:142: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). if (!pw->pw_dir || strlen(pw->pw_dir) ==0 || strstr(pw->pw_dir, "/./") == NULL) { data/jailkit-2.21/src/jk_socketd.c:121:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(serv_addr.sun_path, sl->inpath, sizeof(serv_addr.sun_path)); data/jailkit-2.21/src/jk_socketd.c:334:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(client_addr.sa_data, "/dev/log", sizeof(client_addr.sa_data)); data/jailkit-2.21/src/jk_socketd.c:370: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). secpos = prevpos - strlen(tmp)-4; data/jailkit-2.21/src/jk_uchroot.c:164: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). if (tmp && strlen(tmp)) { data/jailkit-2.21/src/jk_uchroot.c:177: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). if (!pw->pw_name || strlen(pw->pw_name)==0) { data/jailkit-2.21/src/jk_uchroot.c:244: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(jail)+strlen(executable)+2; data/jailkit-2.21/src/jk_uchroot.c:244: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). len = strlen(jail)+strlen(executable)+2; data/jailkit-2.21/src/jk_uchroot.c:263:36: [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). groupsec = strcat(strcpy(malloc0(strlen(gr->gr_name)+7), "group "), gr->gr_name); data/jailkit-2.21/src/jk_uchroot.c:278:56: [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 pos = iniparser_get_position(parser) - strlen(section) - 2; data/jailkit-2.21/src/passwdparser.c:166: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). || strlen(retpw.pw_name)<1 || strlen(retpw.pw_dir)<1 || strlen(retpw.pw_shell)<1) { data/jailkit-2.21/src/passwdparser.c:166:35: [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(retpw.pw_name)<1 || strlen(retpw.pw_dir)<1 || strlen(retpw.pw_shell)<1) { data/jailkit-2.21/src/passwdparser.c:166:61: [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(retpw.pw_name)<1 || strlen(retpw.pw_dir)<1 || strlen(retpw.pw_shell)<1) { data/jailkit-2.21/src/utils.c:81:16: [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 dest + strlen(src); data/jailkit-2.21/src/wordexp.c:142: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). len = strlen(str); data/jailkit-2.21/src/wordexp.c:787:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((buflen = read(fildes[0], buffer, bufsize)) < 1) { data/jailkit-2.21/src/wordexp.c:790:19: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((buflen = read(fildes[0], buffer, bufsize)) < 1) data/jailkit-2.21/src/wordexp.c:809:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((buflen = read(fildes[0], buffer, bufsize)) < 1) { data/jailkit-2.21/src/wordexp.c:812:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((read(fildes[0], buffer, bufsize)) < 1) data/jailkit-2.21/src/wordexp.c:1188: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). plist_len += strlen(libc_argv[p]) + 1; /* for space */ data/jailkit-2.21/src/wordexp.c:1395:19: [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). end = value + strlen(value); data/jailkit-2.21/src/wordexp.c:1595: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). my_itoa(value ? strlen(value) : 0, param_length, 20)); ANALYSIS SUMMARY: Hits = 149 Lines analyzed = 5667 in approximately 0.25 seconds (22915 lines/second) Physical Source Lines of Code (SLOC) = 4055 Hits@level = [0] 224 [1] 54 [2] 44 [3] 13 [4] 37 [5] 1 Hits@level+ = [0+] 373 [1+] 149 [2+] 95 [3+] 51 [4+] 38 [5+] 1 Hits/KSLOC@level+ = [0+] 91.9852 [1+] 36.7448 [2+] 23.4279 [3+] 12.5771 [4+] 9.37115 [5+] 0.246609 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.