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/gesftpserver-1~ds/xfns.h Examining data/gesftpserver-1~ds/pwtest.c Examining data/gesftpserver-1~ds/getopt1.c Examining data/gesftpserver-1~ds/sftp.h Examining data/gesftpserver-1~ds/xfns.c Examining data/gesftpserver-1~ds/getopt.c Examining data/gesftpserver-1~ds/utils.h Examining data/gesftpserver-1~ds/debug.c Examining data/gesftpserver-1~ds/serialize.c Examining data/gesftpserver-1~ds/sftpclient.c Examining data/gesftpserver-1~ds/v3.c Examining data/gesftpserver-1~ds/handle.c Examining data/gesftpserver-1~ds/readwrite.c Examining data/gesftpserver-1~ds/getcwd.c Examining data/gesftpserver-1~ds/users.h Examining data/gesftpserver-1~ds/queue.h Examining data/gesftpserver-1~ds/v6.c Examining data/gesftpserver-1~ds/sftpclient.h Examining data/gesftpserver-1~ds/debug.h Examining data/gesftpserver-1~ds/handle.h Examining data/gesftpserver-1~ds/stat.c Examining data/gesftpserver-1~ds/send.c Examining data/gesftpserver-1~ds/sftpserver.c Examining data/gesftpserver-1~ds/alloc.c Examining data/gesftpserver-1~ds/charset.h Examining data/gesftpserver-1~ds/realpath.c Examining data/gesftpserver-1~ds/parse.c Examining data/gesftpserver-1~ds/futimes.c Examining data/gesftpserver-1~ds/thread.h Examining data/gesftpserver-1~ds/charset.c Examining data/gesftpserver-1~ds/parse.h Examining data/gesftpserver-1~ds/alloc.h Examining data/gesftpserver-1~ds/sftpcommon.h Examining data/gesftpserver-1~ds/serialize.h Examining data/gesftpserver-1~ds/globals.c Examining data/gesftpserver-1~ds/putword.h Examining data/gesftpserver-1~ds/dirname.c Examining data/gesftpserver-1~ds/v4.c Examining data/gesftpserver-1~ds/status.c Examining data/gesftpserver-1~ds/types.h Examining data/gesftpserver-1~ds/sftpserver.h Examining data/gesftpserver-1~ds/readlink.c Examining data/gesftpserver-1~ds/queue.c Examining data/gesftpserver-1~ds/users.c Examining data/gesftpserver-1~ds/utils.c Examining data/gesftpserver-1~ds/getopt.h Examining data/gesftpserver-1~ds/daemon.c Examining data/gesftpserver-1~ds/send.h Examining data/gesftpserver-1~ds/globals.h Examining data/gesftpserver-1~ds/v5.c Examining data/gesftpserver-1~ds/stat.h FINAL RESULTS: data/gesftpserver-1~ds/readlink.c:36:9: [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. n = readlink(path, result, nresult); data/gesftpserver-1~ds/stat.c:447:10: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. return chown(what, uid, gid); data/gesftpserver-1~ds/stat.c:456:10: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. return chmod(what, mode); data/gesftpserver-1~ds/debug.c:92:3: [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(debugfp, fmt, ap); data/gesftpserver-1~ds/debug.h:48:64: [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. void sftp_debug_printf(const char *fmt, ...) attribute((format(printf,1,2))); data/gesftpserver-1~ds/realpath.c:53:5: [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(abspath, cwd); data/gesftpserver-1~ds/realpath.c:55:5: [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, path); data/gesftpserver-1~ds/sftpclient.c:187:30: [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. static int attribute((format(printf,1,2))) error(const char *fmt, ...) { data/gesftpserver-1~ds/sftpclient.c:193:3: [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, fmt, ap); data/gesftpserver-1~ds/sftpclient.c:973:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(full, "%s/%s", cwd, av[0]); data/gesftpserver-1~ds/sftpclient.c:1164:11: [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(fullname, path); data/gesftpserver-1~ds/sftpclient.c:1166:11: [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(fullname, attrs->name); data/gesftpserver-1~ds/sftpclient.c:1243:5: [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(args[0], (void *)args); data/gesftpserver-1~ds/sftpclient.c:1630:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(r.tmp, "%s.new", r.local); data/gesftpserver-1~ds/sftpclient.c:1963:13: [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(ptr, newline); data/gesftpserver-1~ds/sftpclient.c:2844:14: [4] (shell) system: 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. rc = system(line + 1); data/gesftpserver-1~ds/sftpclient.c:2846:14: [4] (shell) system: 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. rc = system(getenv("SHELL")); data/gesftpserver-1~ds/sftpclient.c:3041:7: [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(cmdline[0], (void *)cmdline); data/gesftpserver-1~ds/sftpserver.c:457:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf((char *)sftp_debugpath, "%s/.gesftpserver.%ju", data/gesftpserver-1~ds/stat.c:175:5: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(linkcount, "%"PRIu32, attrs->link_count); data/gesftpserver-1~ds/stat.c:180:5: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(size, "%"PRIu64, attrs->size); data/gesftpserver-1~ds/stat.c:185:5: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(nowner, "%"PRIu32, attrs->uid); data/gesftpserver-1~ds/stat.c:186:5: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(ngroup, "%"PRIu32, attrs->gid); data/gesftpserver-1~ds/stat.c:239:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(formatted, "%10.10s %3.3s %-8.8s %-8.8s %8.8s %12.12s %s%s%s%s%s", data/gesftpserver-1~ds/users.c:43:9: [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). s = strcpy(sftp_alloc(a, strlen(pw->pw_name) + 1), pw->pw_name); data/gesftpserver-1~ds/users.c:56:9: [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). s = strcpy(sftp_alloc(a, strlen(gr->gr_name) + 1), gr->gr_name); data/gesftpserver-1~ds/utils.c:102:10: [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). return strcpy(xmalloc(strlen(s) + 1), s); data/gesftpserver-1~ds/utils.c:115:5: [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, ap); data/gesftpserver-1~ds/utils.h:187:21: [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. attribute((format(printf,1,2))); data/gesftpserver-1~ds/v3.c:431:17: [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). childpath = strcpy(sftp_alloc(job->a, strlen(de->d_name) + 1), de->d_name); data/gesftpserver-1~ds/v3.c:434:5: [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(fullpath, path); data/gesftpserver-1~ds/v3.c:436:5: [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(fullpath, childpath); data/gesftpserver-1~ds/v6.c:53:9: [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(newpath, path); data/gesftpserver-1~ds/v6.c:55:9: [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(newpath, compose); data/gesftpserver-1~ds/xfns.c:50:8: [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. rc = vfprintf(stdout, fmt, ap); data/gesftpserver-1~ds/xfns.h:55:53: [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. int xprintf(const char *fmt, ...) attribute((format(printf,1,2))); data/gesftpserver-1~ds/getopt.c:210: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. #ifndef getenv data/gesftpserver-1~ds/getopt.c:211:14: [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. extern char *getenv (); data/gesftpserver-1~ds/getopt.c:403:21: [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. posixly_correct = getenv ("POSIXLY_CORRECT"); data/gesftpserver-1~ds/getopt.c:972:1: [3] (buffer) getopt: 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 (argc, argv, optstring) data/gesftpserver-1~ds/getopt.c:1002:11: [3] (buffer) getopt: 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 (argc, argv, "abc:d:0123456789"); data/gesftpserver-1~ds/getopt.h:134:12: [3] (buffer) getopt: 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. extern int getopt (int __argc, char *const *__argv, const char *__shortopts); data/gesftpserver-1~ds/getopt.h:136:12: [3] (buffer) getopt: 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. extern int getopt (); data/gesftpserver-1~ds/getopt.h:140:12: [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. extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, data/gesftpserver-1~ds/getopt.h:153:12: [3] (buffer) getopt: 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. extern int getopt (); data/gesftpserver-1~ds/getopt.h:155:12: [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. extern int getopt_long (); data/gesftpserver-1~ds/getopt1.c:67:1: [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, options, long_options, opt_index) data/gesftpserver-1~ds/getopt1.c:123: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. c = getopt_long (argc, argv, "abc:d:0123456789", data/gesftpserver-1~ds/sftpclient.c:2846:21: [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. rc = system(getenv("SHELL")); data/gesftpserver-1~ds/sftpclient.c:2912: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. if((e = getenv("COLUMNS"))) data/gesftpserver-1~ds/sftpclient.c:2920:14: [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. while((n = getopt_long(argc, argv, "hVrB:b:P:R:s:S:12CF:o:vdH:p:46D:", data/gesftpserver-1~ds/sftpserver.c:454:24: [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. const char *home = getenv("HOME"); data/gesftpserver-1~ds/sftpserver.c:469:14: [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. while((n = getopt_long(argc, argv, "hVdD:r:u:H:L:b46R", data/gesftpserver-1~ds/sftpserver.c:569:8: [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(".") < 0) data/gesftpserver-1~ds/alloc.c:156:5: [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(newptr, ptr, oldn); data/gesftpserver-1~ds/daemon.c:58:24: [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(!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) { data/gesftpserver-1~ds/debug.c:48:16: [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(sftp_debugpath, O_WRONLY|O_CREAT|O_TRUNC, 0600)) >= 0) data/gesftpserver-1~ds/debug.c:61: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[80], *output; data/gesftpserver-1~ds/debug.c:66:15: [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. output += sprintf(output, "%4lx ", (unsigned long)i); data/gesftpserver-1~ds/debug.c:69:12: [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. output += sprintf(output, " %02x", p[i + j]); data/gesftpserver-1~ds/debug.c:71: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. strcpy(output, " "); data/gesftpserver-1~ds/debug.c:74:5: [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(output, " "); data/gesftpserver-1~ds/dirname.c:37: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(d, path, len); data/gesftpserver-1~ds/parse.c:81:5: [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(str, job->ptr, len); data/gesftpserver-1~ds/pwtest.c:26:12: [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 buffer[16]; data/gesftpserver-1~ds/send.c:129: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(w->buffer + w->bufused, bytes, n); data/gesftpserver-1~ds/sftpclient.c:109: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. static const char *sshoptions[1024]; data/gesftpserver-1~ds/sftpclient.c:1067: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(tmp, base + n * size, size); data/gesftpserver-1~ds/sftpclient.c:1068: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(base + n * size, base + (count - n - 1) * size, size); data/gesftpserver-1~ds/sftpclient.c:1069: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(base + (count - n - 1) * size, tmp, size); data/gesftpserver-1~ds/sftpclient.c:1302:17: [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). attrs.uid = atoi(av[0]); data/gesftpserver-1~ds/sftpclient.c:1320:17: [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). attrs.gid = atoi(av[0]); data/gesftpserver-1~ds/sftpclient.c:1631:14: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if((r.fd = open(r.tmp, O_WRONLY|O_TRUNC|O_CREAT, 0666)) < 0) { data/gesftpserver-1~ds/sftpclient.c:1873:11: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if((fd = open(local, O_RDONLY)) < 0) { data/gesftpserver-1~ds/sftpclient.c:2455: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[128]; data/gesftpserver-1~ds/sftpclient.c:2465: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("dest", O_RDWR)) < 0) { data/gesftpserver-1~ds/sftpclient.c:2801: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[4096]; data/gesftpserver-1~ds/sftpclient.c:2831: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 *avbuf[256], **av; data/gesftpserver-1~ds/sftpclient.c:2926:28: [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). case 'B': buffersize = atoi(optarg); break; data/gesftpserver-1~ds/sftpclient.c:2929:27: [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). case 'R': nrequests = atoi(optarg); break; data/gesftpserver-1~ds/sftpclient.c:2931:29: [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). case 'S': sftpversion = atoi(optarg); break; data/gesftpserver-1~ds/sftpclient.c:2947:29: [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). case 263: sftpversion = atoi(optarg); forceversion = 1; break; data/gesftpserver-1~ds/sftpclient.c:2994: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. const char *cmdline[2048]; data/gesftpserver-1~ds/sftpclient.c:3066: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). if(!(fp = fopen(batchfile, "r"))) data/gesftpserver-1~ds/stat.c:135: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 perms[64], linkcount[64], size[64], date[64], nowner[64], ngroup[64]; data/gesftpserver-1~ds/stat.c:172:5: [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(p, "?????????"); data/gesftpserver-1~ds/utils.c:154: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(s + ls, t, lt); data/gesftpserver-1~ds/v5.c:168: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). fd = open(path, open_flags|O_CREAT|O_EXCL, initial_permissions); data/gesftpserver-1~ds/v5.c:177: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). fd = open(path, open_flags|O_CREAT, initial_permissions); data/gesftpserver-1~ds/v5.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). fd = open(path, open_flags|O_CREAT|O_EXCL, initial_permissions); data/gesftpserver-1~ds/v5.c:204:14: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = open(path, open_flags, initial_permissions); data/gesftpserver-1~ds/v5.c:216:14: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = open(path, open_flags, initial_permissions); data/gesftpserver-1~ds/v5.c:223:14: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = open(path, open_flags|O_CREAT, initial_permissions); data/gesftpserver-1~ds/v5.c:239:10: [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, open_flags, initial_permissions); data/gesftpserver-1~ds/v5.c:253:10: [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, open_flags|O_TRUNC, initial_permissions); data/gesftpserver-1~ds/v5.c:372: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[8192]; data/gesftpserver-1~ds/charset.c:48: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). const size_t inputsize = strlen(input); data/gesftpserver-1~ds/charset.c:49: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). size_t outputsize = 2 * strlen(input) + 1; data/gesftpserver-1~ds/getopt.c:233: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). # if (!defined __STDC__ || !__STDC__) && !defined strlen data/gesftpserver-1~ds/getopt.c:236: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). extern int strlen (const char *); data/gesftpserver-1~ds/getopt.c:434: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). int len = nonoption_flags_max_len = strlen (orig_str); data/gesftpserver-1~ds/getopt.c:659: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) strlen (p->name)) data/gesftpserver-1~ds/getopt.c:683: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). nextchar += strlen (nextchar); data/gesftpserver-1~ds/getopt.c:715: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). nextchar += strlen (nextchar); data/gesftpserver-1~ds/getopt.c:731: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). nextchar += strlen (nextchar); data/gesftpserver-1~ds/getopt.c:736: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). nextchar += strlen (nextchar); data/gesftpserver-1~ds/getopt.c:847: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). if ((unsigned int) (nameend - nextchar) == strlen (p->name)) data/gesftpserver-1~ds/getopt.c:870: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). nextchar += strlen (nextchar); data/gesftpserver-1~ds/getopt.c:890: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). nextchar += strlen (nextchar); data/gesftpserver-1~ds/getopt.c:904: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). nextchar += strlen (nextchar); data/gesftpserver-1~ds/getopt.c:908: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). nextchar += strlen (nextchar); data/gesftpserver-1~ds/realpath.c:52: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). abspath = sftp_alloc(a, strlen(cwd) + strlen(path) + 2); data/gesftpserver-1~ds/realpath.c:52:43: [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). abspath = sftp_alloc(a, strlen(cwd) + strlen(path) + 2); data/gesftpserver-1~ds/realpath.c:54: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(abspath, "/"); data/gesftpserver-1~ds/realpath.c:95:11: [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(result, "/"); /* /.. = / */ data/gesftpserver-1~ds/realpath.c:98: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). const size_t oldresultlen = strlen(result); data/gesftpserver-1~ds/realpath.c:112:15: [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(result, "/"); data/gesftpserver-1~ds/send.c:134: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). sftp_send_bytes(w, s, strlen(s)); data/gesftpserver-1~ds/sftpclient.c:448: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). if(buffersize < strlen(newline)) data/gesftpserver-1~ds/sftpclient.c:449: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). buffersize = strlen(newline); data/gesftpserver-1~ds/sftpclient.c:972: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). char *full = sftp_alloc(fakejob.a, strlen(cwd) + strlen(av[0]) + 2); data/gesftpserver-1~ds/sftpclient.c:972: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). char *full = sftp_alloc(fakejob.a, strlen(cwd) + strlen(av[0]) + 2); data/gesftpserver-1~ds/sftpclient.c:1162: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). strlen(path) + strlen(attrs->name) data/gesftpserver-1~ds/sftpclient.c:1162: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). strlen(path) + strlen(attrs->name) data/gesftpserver-1~ds/sftpclient.c:1165:11: [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(fullname, "/"); data/gesftpserver-1~ds/sftpclient.c:1271:5: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(n); data/gesftpserver-1~ds/sftpclient.c:1273:9: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). n = umask(0); data/gesftpserver-1~ds/sftpclient.c:1274:5: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(n); data/gesftpserver-1~ds/sftpclient.c:1629: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). r.tmp = sftp_alloc(fakejob.a, strlen(r.local) + 5); data/gesftpserver-1~ds/sftpclient.c:1952: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). const size_t newline_len = strlen(newline); data/gesftpserver-1~ds/sftpclient.c:1957:30: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while(left > 0 && (c = getc(fp)) != EOF) { data/gesftpserver-1~ds/sftpclient.c:1986:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). n = read(fd, fakejob.worker->buffer + fakejob.worker->bufused + 4, data/gesftpserver-1~ds/sftpclient.c:2137: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). xprintf("%s:%*s ", what, width - (int)strlen(what), ""); data/gesftpserver-1~ds/sftpclient.c:2512:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). r = read(fd, buffer, sizeof buffer); data/gesftpserver-1~ds/sftpclient.c:2780: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(commands[n].name); data/gesftpserver-1~ds/sftpclient.c:2782: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). len += strlen(commands[n].args) + 1; data/gesftpserver-1~ds/sftpclient.c:2789: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(commands[n].name); data/gesftpserver-1~ds/sftpclient.c:2792: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). len += strlen(commands[n].args) + 1; data/gesftpserver-1~ds/sftpserver.c:456:30: [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). sftp_debugpath = xmalloc(strlen(home) + 40); data/gesftpserver-1~ds/sftpserver.c:648:3: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(0); data/gesftpserver-1~ds/stat.c:96: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). const char *s = path + strlen(path); data/gesftpserver-1~ds/stat.c:177:5: [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(linkcount, "?"); data/gesftpserver-1~ds/stat.c:182:5: [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(size, "?"); data/gesftpserver-1~ds/stat.c:218:5: [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(date, "?"); data/gesftpserver-1~ds/stat.c:236: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). formatted = sftp_alloc(a, 80 + strlen(attrs->name)); data/gesftpserver-1~ds/users.c:43:30: [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). s = strcpy(sftp_alloc(a, strlen(pw->pw_name) + 1), pw->pw_name); data/gesftpserver-1~ds/users.c:56:30: [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). s = strcpy(sftp_alloc(a, strlen(gr->gr_name) + 1), gr->gr_name); data/gesftpserver-1~ds/utils.c:43:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). n = read(fd, ptr + sofar, size - sofar); data/gesftpserver-1~ds/utils.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). return strcpy(xmalloc(strlen(s) + 1), s); data/gesftpserver-1~ds/utils.c:138: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). const size_t ls = s ? strlen(s) : 0, need = lt + ls + 1; data/gesftpserver-1~ds/utils.c:161: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). return appendn(a, s, ns, t, strlen(t)); data/gesftpserver-1~ds/v3.c:347: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(targetpath) == 0) { data/gesftpserver-1~ds/v3.c:431:43: [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). childpath = strcpy(sftp_alloc(job->a, strlen(de->d_name) + 1), de->d_name); data/gesftpserver-1~ds/v3.c:433: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). fullpath = sftp_alloc(job->a, strlen(path) + strlen(childpath) + 2); data/gesftpserver-1~ds/v3.c:433: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). fullpath = sftp_alloc(job->a, strlen(path) + strlen(childpath) + 2); data/gesftpserver-1~ds/v3.c:435: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(fullpath, "/"); data/gesftpserver-1~ds/v3.c:681:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). n = read(fd, job->worker->buffer + job->worker->bufused + 4, len); data/gesftpserver-1~ds/v5.c:393:26: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while(line > 0 && (n = read(fd, buffer, sizeof buffer)) > 0) { data/gesftpserver-1~ds/v6.c:51: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). char *newpath = sftp_alloc(job->a, strlen(path) + strlen(compose) + 2); data/gesftpserver-1~ds/v6.c:51:59: [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 *newpath = sftp_alloc(job->a, strlen(path) + strlen(compose) + 2); data/gesftpserver-1~ds/v6.c:54:9: [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(newpath, "/"); data/gesftpserver-1~ds/v6.c:125: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). if(symbolic && strlen(oldpath) == 0) { ANALYSIS SUMMARY: Hits = 162 Lines analyzed = 13006 in approximately 0.39 seconds (33674 lines/second) Physical Source Lines of Code (SLOC) = 7888 Hits@level = [0] 41 [1] 66 [2] 42 [3] 18 [4] 33 [5] 3 Hits@level+ = [0+] 203 [1+] 162 [2+] 96 [3+] 54 [4+] 36 [5+] 3 Hits/KSLOC@level+ = [0+] 25.7353 [1+] 20.5375 [2+] 12.1704 [3+] 6.84584 [4+] 4.56389 [5+] 0.380325 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.