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/sbrsh-7.6.1/buffer.c Examining data/sbrsh-7.6.1/buffer.h Examining data/sbrsh-7.6.1/client.c Examining data/sbrsh-7.6.1/client.h Examining data/sbrsh-7.6.1/common.c Examining data/sbrsh-7.6.1/common.h Examining data/sbrsh-7.6.1/config.c Examining data/sbrsh-7.6.1/config.h Examining data/sbrsh-7.6.1/daemon.c Examining data/sbrsh-7.6.1/daemon.h Examining data/sbrsh-7.6.1/doc/interaction-command.c Examining data/sbrsh-7.6.1/fakeroot.c Examining data/sbrsh-7.6.1/fakeroot.h Examining data/sbrsh-7.6.1/fakeroot/config.h Examining data/sbrsh-7.6.1/fakeroot/message.h Examining data/sbrsh-7.6.1/mount.c Examining data/sbrsh-7.6.1/mount.h Examining data/sbrsh-7.6.1/protocol.c Examining data/sbrsh-7.6.1/protocol.h Examining data/sbrsh-7.6.1/sb-exportfs.c Examining data/sbrsh-7.6.1/types.h Examining data/sbrsh-7.6.1/version.h FINAL RESULTS: data/sbrsh-7.6.1/client.c:86:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, msg, arg); data/sbrsh-7.6.1/client.c:114:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, msg, arg); data/sbrsh-7.6.1/client.c:651:7: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. if (sscanf(remote_user, "%d,%d,%s", &uid, &gid, username) != 3) { data/sbrsh-7.6.1/client.c:668: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(username, userstruct->pw_name); data/sbrsh-7.6.1/client.c:675:4: [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(username, str); data/sbrsh-7.6.1/client.c:761:4: [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(path, home); data/sbrsh-7.6.1/client.c:762:4: [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(path, "/" CONFIG_NAME); data/sbrsh-7.6.1/common.c:311: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(str, piece); data/sbrsh-7.6.1/daemon.c:134:3: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(debug_filename, DEFAULT_DEBUG_FILENAME_FMT, port); data/sbrsh-7.6.1/daemon.c:179:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(debug_file, msg, arg); data/sbrsh-7.6.1/daemon.c:211:2: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. vsnprintf(str, sizeof (str) - 1, msg, arg); data/sbrsh-7.6.1/daemon.c:217: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(str, err); data/sbrsh-7.6.1/daemon.c:355: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(argv[0], argv); data/sbrsh-7.6.1/daemon.c:1113:4: [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(cpy, device + strlen(PROC_MOUNTS_SSHFS)); data/sbrsh-7.6.1/daemon.c:1123:4: [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(cpy, device); data/sbrsh-7.6.1/daemon.c:1837: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(dir, orig); data/sbrsh-7.6.1/daemon.c:2000:2: [4] (shell) execvp: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execvp(argv[0], argv); data/sbrsh-7.6.1/daemon.c:2200:3: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf(root, sizeof (root) - 1, SANDBOX_ROOT "/%s@%s/%s", data/sbrsh-7.6.1/daemon.c:2664: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(abspath, file); data/sbrsh-7.6.1/fakeroot.c:466:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(data->fakerootkey, FAKEROOTKEY_ENV "=%d", port); data/sbrsh-7.6.1/mount.c:268: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(renamed, scratchbox); data/sbrsh-7.6.1/mount.c:269: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(renamed, path + alias_len); data/sbrsh-7.6.1/sb-exportfs.c:53:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(homedir, SB_HOME_DIR, user); data/sbrsh-7.6.1/sb-exportfs.c:54:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(targetdir, SB_TARGET_DIR, user, target); data/sbrsh-7.6.1/sb-exportfs.c:55:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(targetsdir, SB_TARGETS_DIR, user); data/sbrsh-7.6.1/sb-exportfs.c:121:3: [4] (shell) execlp: 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. execlp("exportfs", "exportfs", "-r", NULL); data/sbrsh-7.6.1/sb-exportfs.c:144:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(sbrsh_config, "%s/%s/home/%s/.sbrsh", SB_USERS_DIR, data/sbrsh-7.6.1/sb-exportfs.c:190:6: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cp, "%s:/%s", cfg->host, path); data/sbrsh-7.6.1/sb-exportfs.c:193:6: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(opts, MOUNT_OPTS, pwds->pw_uid, pwds->pw_gid); data/sbrsh-7.6.1/sb-exportfs.c:197:7: [4] (shell) execlp: 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. execlp("exportfs", "exportfs", "-i", "-o", opts, cp, data/sbrsh-7.6.1/client.c:574:7: [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, "hvt:c:d:r:", longopts, NULL); data/sbrsh-7.6.1/client.c:673:9: [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. str = getenv("_SBOX_NONFAKE_USER"); data/sbrsh-7.6.1/client.c:678:9: [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. str = getenv("_SBOX_NONFAKE_UID"); data/sbrsh-7.6.1/client.c:684:9: [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. str = getenv("_SBOX_NONFAKE_GID"); data/sbrsh-7.6.1/client.c:755: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. home = getenv("HOME"); data/sbrsh-7.6.1/daemon.c:409:15: [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. real_mount = realpath(mount_cmd, mount_buf); data/sbrsh-7.6.1/daemon.c:909:11: [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. point1 = realpath(point, buf1); data/sbrsh-7.6.1/daemon.c:929:12: [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. point2 = realpath(point2tmp, buf2); data/sbrsh-7.6.1/daemon.c:1077:11: [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. point1 = realpath(point, buf1); data/sbrsh-7.6.1/daemon.c:1097:12: [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. point2 = realpath(point2tmp, buf2); data/sbrsh-7.6.1/daemon.c:1781:9: [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. str = getenv(info[i].key); data/sbrsh-7.6.1/daemon.c:1857:7: [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(dir) < 0) { data/sbrsh-7.6.1/daemon.c:1976:13: [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. argv[0] = getenv("SHELL"); data/sbrsh-7.6.1/daemon.c:2652:12: [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. abspath = realpath(dir, abspath); data/sbrsh-7.6.1/daemon.c:2722:11: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. int c = getopt_long(argc, argv, optstring, longopts, NULL); data/sbrsh-7.6.1/fakeroot.c:441: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. str = getenv(FAKEROOTKEY_ENV); data/sbrsh-7.6.1/mount.c:253:10: [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. alias = getenv("_SBOX_DIR"); data/sbrsh-7.6.1/buffer.c:106: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(mem, buf->mem, buf->mem_size); data/sbrsh-7.6.1/client.c:679:21: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (str && (uid = atoi(str)) <= 0) { data/sbrsh-7.6.1/client.c:685:21: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (str && (gid = atoi(str)) <= 0) { data/sbrsh-7.6.1/client.c:707: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 user[NAME_MAX]; data/sbrsh-7.6.1/config.c:140: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[1024], *bufp; data/sbrsh-7.6.1/config.c:144:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). file = fopen(filename, "r"); data/sbrsh-7.6.1/config.c:211: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[1024]; data/sbrsh-7.6.1/config.c:216:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). file = fopen(filename, "r"); data/sbrsh-7.6.1/daemon.c:137: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). debug_file = fopen(debug_filename, "a"); data/sbrsh-7.6.1/daemon.c:208: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 str[1024] = { '\0' }, *err; data/sbrsh-7.6.1/daemon.c:216: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(str, " ("); data/sbrsh-7.6.1/daemon.c:309: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 line[1024]; data/sbrsh-7.6.1/daemon.c:407: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 mount_buf[PATH_MAX], *real_mount; data/sbrsh-7.6.1/daemon.c:430:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). file = fopen(filename, "r"); data/sbrsh-7.6.1/daemon.c:523:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). file = fopen(filename, "w"); data/sbrsh-7.6.1/daemon.c:592: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(vec, lines, sizeof (char *) * oldlineslen); data/sbrsh-7.6.1/daemon.c:798: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 *argv[8]; data/sbrsh-7.6.1/daemon.c:907: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[1024], buf1[PATH_MAX], buf2[PATH_MAX], *point1; data/sbrsh-7.6.1/daemon.c:913:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). file = fopen(MOUNTS_FILE, "r"); data/sbrsh-7.6.1/daemon.c:1075: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[1024], buf1[PATH_MAX], buf2[PATH_MAX], *point1; data/sbrsh-7.6.1/daemon.c:1081:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). file = fopen(MOUNTS_FILE, "r"); data/sbrsh-7.6.1/daemon.c:1143: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 remote_path[PATH_MAX] = { 0 }; /* On Linux path max is 4096 */ data/sbrsh-7.6.1/daemon.c:1779: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. resname = (char *) info[i].key + prefixlen; data/sbrsh-7.6.1/daemon.c:1799:19: [2] (integer) atol: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). lim.rlim_cur = atol(str); data/sbrsh-7.6.1/daemon.c:2198: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 root[PATH_MAX]; data/sbrsh-7.6.1/daemon.c:2226: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 tmp[PATH_MAX], *str; data/sbrsh-7.6.1/daemon.c:2796: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). int i = atoi(exp_str); data/sbrsh-7.6.1/daemon.c:2832: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(NULL_FILE, O_RDWR); data/sbrsh-7.6.1/daemon.h:109: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 host[NI_MAXHOST]; data/sbrsh-7.6.1/daemon.h:138: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_buf[BUFFER_SIZE]; data/sbrsh-7.6.1/fakeroot.c:449:9: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). port = atoi(str); data/sbrsh-7.6.1/mount.c:150: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 host[MAXHOSTNAMELEN], *path; data/sbrsh-7.6.1/mount.c:179: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[1024]; data/sbrsh-7.6.1/mount.c:180: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. struct { char nfs_path[PATH_MAX], *path; } sel; data/sbrsh-7.6.1/mount.c:184:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). file = fopen(MOUNTS_FILE, "r"); data/sbrsh-7.6.1/protocol.c:37:10: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char path[PATH_MAX]; data/sbrsh-7.6.1/protocol.c:40:10: [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 = fopen(path, "w"); data/sbrsh-7.6.1/protocol.c:65:52: [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. fprintf(file, "%02x", (unsigned int) ((unsigned char *) buf)[i]); data/sbrsh-7.6.1/protocol.c:91:52: [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. fprintf(file, "%02x", (unsigned int) ((unsigned char *) buf)[i]); data/sbrsh-7.6.1/client.c:177:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). len = read(STDIN_FILENO, tmp_buf, len); data/sbrsh-7.6.1/client.c:338:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (is_tty || read(STDIN_FILENO,NULL,0)!=-1) { data/sbrsh-7.6.1/client.c:485: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). is_long = strlen(arg) > 2; data/sbrsh-7.6.1/client.c:756: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). path = malloc(strlen(home) + strlen("/" CONFIG_NAME) + 1); data/sbrsh-7.6.1/client.c:756: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). path = malloc(strlen(home) + strlen("/" CONFIG_NAME) + 1); data/sbrsh-7.6.1/client.c:1056:20: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). uint16_t mask = umask(0); data/sbrsh-7.6.1/client.c:1057:4: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(mask); data/sbrsh-7.6.1/common.c:88: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 (p && strlen(p) >= 2) data/sbrsh-7.6.1/common.c:160:7: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc(file); data/sbrsh-7.6.1/common.c:260: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(line) == 0) { data/sbrsh-7.6.1/common.c:273: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(str) > 0) { data/sbrsh-7.6.1/common.c:300: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). avail = (bufsize - 1) - strlen(str); data/sbrsh-7.6.1/common.c:305: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(piece); data/sbrsh-7.6.1/common.c:307:4: [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. strncat(str, piece, avail); data/sbrsh-7.6.1/common.c:318: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). return strlen(buf); data/sbrsh-7.6.1/config.c:108: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(buf) == 0) data/sbrsh-7.6.1/config.c:127: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(buf) == 0) data/sbrsh-7.6.1/daemon.c:128: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). debug_filename = malloc(strlen(DEFAULT_DEBUG_FILENAME_FMT) + 5); data/sbrsh-7.6.1/daemon.c:212: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/sbrsh-7.6.1/daemon.c:215: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). if (errno && err && (len + strlen(err) + 3) < sizeof (str)) { data/sbrsh-7.6.1/daemon.c:218:3: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(str, ")"); data/sbrsh-7.6.1/daemon.c:220: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(str); data/sbrsh-7.6.1/daemon.c:369:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). len = read(err[0], &c, 1); data/sbrsh-7.6.1/daemon.c:441:11: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c = fgetc(file); data/sbrsh-7.6.1/daemon.c:468:12: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c = fgetc(file); data/sbrsh-7.6.1/daemon.c:502: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(line) > 0) data/sbrsh-7.6.1/daemon.c:534: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(line); data/sbrsh-7.6.1/daemon.c:572: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(host) == ptr - line && data/sbrsh-7.6.1/daemon.c:661: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). if (!star && strlen(data->host) != len) data/sbrsh-7.6.1/daemon.c:1112:50: [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). strncmp(device, PROC_MOUNTS_SSHFS, strlen(PROC_MOUNTS_SSHFS)) == 0)) { data/sbrsh-7.6.1/daemon.c:1113: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). strcat(cpy, device + strlen(PROC_MOUNTS_SSHFS)); data/sbrsh-7.6.1/daemon.c:1116: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). return strlen(cpy); data/sbrsh-7.6.1/daemon.c:1126: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). return strlen(cpy); data/sbrsh-7.6.1/daemon.c:1175:45: [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(mi->point, curr->info.point, strlen(mi->point) - 1) != 0) data/sbrsh-7.6.1/daemon.c:1772: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). const int prefixlen = strlen(ENV_RLIMIT_PREFIX); data/sbrsh-7.6.1/daemon.c:1786: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(str) == 0) data/sbrsh-7.6.1/daemon.c:1798: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). if (strncmp(str, ENV_RLIMIT_UNLIMITED, strlen(ENV_RLIMIT_UNLIMITED)) != 0) { data/sbrsh-7.6.1/daemon.c:1829: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). dir = malloc(1 + strlen(orig) + 1); data/sbrsh-7.6.1/daemon.c:1836:2: [1] (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 character. strcpy(dir, "/"); data/sbrsh-7.6.1/daemon.c:1961:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(data->param.umask); data/sbrsh-7.6.1/daemon.c:1961:20: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(data->param.umask); data/sbrsh-7.6.1/daemon.c:2145:43: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). if (read_uint16(data->sd, &data->param.umask) < 0) { data/sbrsh-7.6.1/daemon.c:2319:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(data->sd, data->tmp_buf, BUFFER_SIZE) <= 0) data/sbrsh-7.6.1/daemon.c:2658:6: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (strlen(abspath) + 1 + strlen(file) > PATH_MAX) { data/sbrsh-7.6.1/daemon.c:2658:28: [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(abspath) + 1 + strlen(file) > PATH_MAX) { data/sbrsh-7.6.1/daemon.c:2663:2: [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(abspath, "/"); data/sbrsh-7.6.1/daemon.c:2823:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(0); data/sbrsh-7.6.1/daemon.c:2882: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(host) == 0 || strchr(host, '@') != NULL) { data/sbrsh-7.6.1/daemon.h:123:12: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). uint16_t umask; data/sbrsh-7.6.1/doc/interaction-command.c:10:9: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (fgetc(stdin) != '\n'); data/sbrsh-7.6.1/fakeroot.c:167:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). len = read(source, &buf, sizeof (buf)); data/sbrsh-7.6.1/fakeroot.c:459: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). data->fakerootkey = malloc(strlen(FAKEROOTKEY_ENV) + 1 + 5 + 1); data/sbrsh-7.6.1/mount.c:160:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(host, fs, MIN(path - fs, sizeof (host) - 1)); data/sbrsh-7.6.1/mount.c:207: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). if (strncmp(r_path, nfs_path, strlen(nfs_path)) != 0) data/sbrsh-7.6.1/mount.c:213: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(sel.nfs_path) < strlen(nfs_path)) data/sbrsh-7.6.1/mount.c:213:31: [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(sel.nfs_path) < strlen(nfs_path)) data/sbrsh-7.6.1/mount.c:226:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(sel.nfs_path, nfs_path, sizeof (sel.nfs_path) - 1); data/sbrsh-7.6.1/mount.c:248: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). const size_t scratchbox_len = strlen(scratchbox); data/sbrsh-7.6.1/mount.c:257: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). alias_len = strlen(alias); data/sbrsh-7.6.1/mount.c:261: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). renamed_len = strlen(path) - alias_len + scratchbox_len + 1; data/sbrsh-7.6.1/protocol.c:82:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). retval = read(fd, buf, len); data/sbrsh-7.6.1/protocol.c:101:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). #define read my_read data/sbrsh-7.6.1/protocol.c:129:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). retval = read(fd, buf, len); data/sbrsh-7.6.1/protocol.c:192: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/sbrsh-7.6.1/protocol.c:275:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). cnt = read(fd, buf + i, len - i); data/sbrsh-7.6.1/sb-exportfs.c:49: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). homedir = alloca(strlen(SB_HOME_DIR) + strlen(user) + 2); data/sbrsh-7.6.1/sb-exportfs.c:49:41: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). homedir = alloca(strlen(SB_HOME_DIR) + strlen(user) + 2); data/sbrsh-7.6.1/sb-exportfs.c:50: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). targetdir = alloca(strlen(SB_TARGET_DIR) + strlen(user) + strlen(target) + 2); data/sbrsh-7.6.1/sb-exportfs.c:50:45: [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). targetdir = alloca(strlen(SB_TARGET_DIR) + strlen(user) + strlen(target) + 2); data/sbrsh-7.6.1/sb-exportfs.c:50:60: [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). targetdir = alloca(strlen(SB_TARGET_DIR) + strlen(user) + strlen(target) + 2); data/sbrsh-7.6.1/sb-exportfs.c:51:22: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). targetsdir = alloca(strlen(SB_TARGETS_DIR) + strlen(user) + 2); data/sbrsh-7.6.1/sb-exportfs.c:51:47: [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). targetsdir = alloca(strlen(SB_TARGETS_DIR) + strlen(user) + 2); data/sbrsh-7.6.1/sb-exportfs.c:58: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). while (mypath[strlen(mypath)] == '/') data/sbrsh-7.6.1/sb-exportfs.c:59: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). mypath[strlen(mypath)] = '\0'; data/sbrsh-7.6.1/sb-exportfs.c:140: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). sbrsh_config = malloc(strlen(SB_USERS_DIR) + data/sbrsh-7.6.1/sb-exportfs.c:141: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). strlen("/home/") + data/sbrsh-7.6.1/sb-exportfs.c:142: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). strlen(file->d_name) * 2 + data/sbrsh-7.6.1/sb-exportfs.c:143: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). strlen("/.sbrsh") + 4); data/sbrsh-7.6.1/sb-exportfs.c:189: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). cp = malloc(strlen(cfg->host) + strlen(path) + 4); data/sbrsh-7.6.1/sb-exportfs.c:189: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). cp = malloc(strlen(cfg->host) + strlen(path) + 4); data/sbrsh-7.6.1/sb-exportfs.c:192:20: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). opts = malloc(strlen(MOUNT_OPTS) + 11); ANALYSIS SUMMARY: Hits = 167 Lines analyzed = 7137 in approximately 0.16 seconds (45187 lines/second) Physical Source Lines of Code (SLOC) = 4880 Hits@level = [0] 41 [1] 81 [2] 39 [3] 17 [4] 30 [5] 0 Hits@level+ = [0+] 208 [1+] 167 [2+] 86 [3+] 47 [4+] 30 [5+] 0 Hits/KSLOC@level+ = [0+] 42.623 [1+] 34.2213 [2+] 17.623 [3+] 9.63115 [4+] 6.14754 [5+] 0 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.