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/webfs-1.21+ds1/mime.c Examining data/webfs-1.21+ds1/cgi.c Examining data/webfs-1.21+ds1/request.c Examining data/webfs-1.21+ds1/httpd.h Examining data/webfs-1.21+ds1/ssl.c Examining data/webfs-1.21+ds1/ls.c Examining data/webfs-1.21+ds1/response.c Examining data/webfs-1.21+ds1/webfsd.c FINAL RESULTS: data/webfs-1.21+ds1/cgi.c:35:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(line,"%s=%s",name,value); data/webfs-1.21+ds1/ls.c:182:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(dest+1,"%s%s%s", data/webfs-1.21+ds1/ls.c:235: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(files[count]->n,file->d_name); data/webfs-1.21+ds1/ls.c:236:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(line,"%s/%s",filename,file->d_name); data/webfs-1.21+ds1/ls.c:269:12: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. len += sprintf(buf+len, data/webfs-1.21+ds1/ls.c:286:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. len += sprintf(buf+len,"<a href=\"%s\">%*.*s</a>", data/webfs-1.21+ds1/ls.c:366:13: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. len += sprintf(buf+len,"<a href=\"%s%s\">%s</a>\n", data/webfs-1.21+ds1/ls.c:371:13: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. len += sprintf(buf+len,"%s\n",files[i]->n); data/webfs-1.21+ds1/ls.c:375:12: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. len += sprintf(buf+len, data/webfs-1.21+ds1/ls.c:481: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(this->path, filename); data/webfs-1.21+ds1/ls.c:482: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(this->mtime, req->mtime); data/webfs-1.21+ds1/mime.c:30: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(mime_types[mime_count].ext, ext); data/webfs-1.21+ds1/mime.c:31: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(mime_types[mime_count].type,type); data/webfs-1.21+ds1/response.c:225:17: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. req->lres = sprintf(req->hres, data/webfs-1.21+ds1/response.c:250:17: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. req->lres = sprintf(req->hres, data/webfs-1.21+ds1/response.c:272:22: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. req->r_hlen[i] = sprintf(req->r_head+i*BR_HEADER, data/webfs-1.21+ds1/response.c:302:17: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. req->lres = sprintf(req->hres, data/webfs-1.21+ds1/response.c:307:15: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. req->lres += sprintf(req->hres+req->lres, data/webfs-1.21+ds1/response.c:313:15: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. req->lres += sprintf(req->hres+req->lres, data/webfs-1.21+ds1/response.c:338:15: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. req->lres += sprintf(req->hres+req->lres, data/webfs-1.21+ds1/response.c:362:17: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. req->lres = sprintf(req->hres, data/webfs-1.21+ds1/response.c:366:15: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. req->lres += sprintf(req->hres+req->lres,"%s\r\n",header->line); data/webfs-1.21+ds1/ssl.c:133: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(buf,password); data/webfs-1.21+ds1/webfsd.c:835:6: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(server_host,res->ai_canonname); data/webfs-1.21+ds1/webfsd.c:931:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cgipath,"%s/",optarg); data/webfs-1.21+ds1/webfsd.c:1047: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(server_host,res->ai_canonname); data/webfs-1.21+ds1/webfsd.c:256:12: [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 (-1 == chroot(doc_root)) { data/webfs-1.21+ds1/webfsd.c:840:17: [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. if (-1 == (c = getopt(argc,argv, options))) data/webfs-1.21+ds1/cgi.c:80:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char host[65],serv[9]; data/webfs-1.21+ds1/cgi.c:81:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char filename[1024], *h, *argv[2], envname[128]; data/webfs-1.21+ds1/cgi.c:123: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). int devnull = open("/dev/null",O_RDWR); data/webfs-1.21+ds1/cgi.c:154:2: [2] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant string. strcpy(envname,"HTTP_"); data/webfs-1.21+ds1/httpd.h:53:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char path[1024]; data/webfs-1.21+ds1/httpd.h:54:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char mtime[40]; data/webfs-1.21+ds1/httpd.h:78:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char peerhost[MAX_HOST+1]; data/webfs-1.21+ds1/httpd.h:79:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char peerserv[MAX_MISC+1]; data/webfs-1.21+ds1/httpd.h:82:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char hreq[MAX_HEADER+1]; /* request header */ data/webfs-1.21+ds1/httpd.h:85:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char type[MAX_MISC+1]; /* req type */ data/webfs-1.21+ds1/httpd.h:86:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char hostname[MAX_HOST+1]; /* hostname */ data/webfs-1.21+ds1/httpd.h:87:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char uri[MAX_PATH+1]; /* req uri */ data/webfs-1.21+ds1/httpd.h:88:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char path[MAX_PATH+1]; /* file path */ data/webfs-1.21+ds1/httpd.h:89:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char query[MAX_PATH+1]; /* query string */ data/webfs-1.21+ds1/httpd.h:91:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char auth[64]; data/webfs-1.21+ds1/httpd.h:106:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char hres[MAX_HEADER+1]; /* response header */ data/webfs-1.21+ds1/httpd.h:113:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char mtime[40]; /* RFC 1123 */ data/webfs-1.21+ds1/httpd.h:122:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char cgibuf[MAX_HEADER+1]; data/webfs-1.21+ds1/ls.c:34: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. static char *cache[CACHE_SIZE]; data/webfs-1.21+ds1/ls.c:72: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. static char *cache[CACHE_SIZE]; data/webfs-1.21+ds1/ls.c:112:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char n[1]; data/webfs-1.21+ds1/ls.c:126:8: [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 do_quote[256]; data/webfs-1.21+ds1/ls.c:145: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. static char buf[2048]; /* FIXME: threads break this... */ data/webfs-1.21+ds1/ls.c:156:2: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf+j,"%%%02x",path[i]); data/webfs-1.21+ds1/ls.c:200:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char line[1024]; data/webfs-1.21+ds1/ls.c:298: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. len += sprintf(buf+len, data/webfs-1.21+ds1/ls.c:323:13: [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. len += sprintf(buf+len,"%-8.8s ",pw); data/webfs-1.21+ds1/ls.c:325:13: [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. len += sprintf(buf+len,"%8d ",(int)files[i]->s.st_uid); data/webfs-1.21+ds1/ls.c:330:13: [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. len += sprintf(buf+len,"%-8.8s ",gr); data/webfs-1.21+ds1/ls.c:332:13: [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. len += sprintf(buf+len,"%8d ",(int)files[i]->s.st_gid); data/webfs-1.21+ds1/ls.c:344:13: [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. len += sprintf(buf+len," <DIR> "); data/webfs-1.21+ds1/ls.c:346:13: [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. len += sprintf(buf+len," -- "); data/webfs-1.21+ds1/ls.c:348:13: [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. len += sprintf(buf+len,"%4d B ", data/webfs-1.21+ds1/ls.c:351:13: [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. len += sprintf(buf+len,"%4d kB ", data/webfs-1.21+ds1/ls.c:354:13: [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. len += sprintf(buf+len,"%4d MB ", data/webfs-1.21+ds1/ls.c:357:13: [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. len += sprintf(buf+len,"%4d GB ", data/webfs-1.21+ds1/ls.c:360:13: [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. len += sprintf(buf+len,"%4d TB ", data/webfs-1.21+ds1/ls.c:367:23: [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. quote((unsigned char *) files[i]->n,9999), data/webfs-1.21+ds1/mime.c:15:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char ext[8]; data/webfs-1.21+ds1/mime.c:16:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char type[64]; data/webfs-1.21+ds1/mime.c:56:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char line[128], type[64], ext[8]; data/webfs-1.21+ds1/mime.c:60:23: [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 (NULL == (fp = fopen(file,"r"))) { data/webfs-1.21+ds1/request.c:96:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char month[4]; data/webfs-1.21+ds1/request.c:353:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char filename[MAX_PATH+1], proto[MAX_MISC+1], *h; data/webfs-1.21+ds1/request.c:529:28: [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 (-1 != (req->bfd = open(filename,O_RDONLY))) { data/webfs-1.21+ds1/request.c:578:27: [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 (-1 == (req->bfd = open(filename,O_RDONLY))) { data/webfs-1.21+ds1/response.c:118:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[BUFSIZE]; data/webfs-1.21+ds1/response.c:233: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. req->lres += sprintf(req->hres+req->lres, data/webfs-1.21+ds1/response.c:327:19: [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. req->r_hlen[i] = sprintf(req->r_head+i*BR_HEADER, data/webfs-1.21+ds1/response.c:331: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. req->lres += sprintf(req->hres+req->lres, data/webfs-1.21+ds1/response.c:360:19: [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). req->status = atoi(status); data/webfs-1.21+ds1/ssl.c:106:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[4 * 4096]; data/webfs-1.21+ds1/webfsd.c:54:1: [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 server_host[256]; data/webfs-1.21+ds1/webfsd.c:55:1: [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[17]; data/webfs-1.21+ds1/webfsd.c:56:1: [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 group[17]; data/webfs-1.21+ds1/webfsd.c:232:20: [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). pw = getpwuid(atoi(user)); data/webfs-1.21+ds1/webfsd.c:238:20: [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). gr = getgrgid(atoi(group)); data/webfs-1.21+ds1/webfsd.c:292:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char timestamp[32]; data/webfs-1.21+ds1/webfsd.c:426:24: [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 (NULL == (logfh = fopen(logfile,"a"))) data/webfs-1.21+ds1/webfsd.c:801:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char host[INET6_ADDRSTRLEN+1]; data/webfs-1.21+ds1/webfsd.c:802:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char serv[16]; data/webfs-1.21+ds1/webfsd.c:803:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char mypid[12]; data/webfs-1.21+ds1/webfsd.c:893:16: [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). timeout = atoi(optarg); data/webfs-1.21+ds1/webfsd.c:896: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). max_conn = atoi(optarg); data/webfs-1.21+ds1/webfsd.c:899: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). max_dircache = atoi(optarg); data/webfs-1.21+ds1/webfsd.c:924: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). lifespan = atoi(optarg); data/webfs-1.21+ds1/webfsd.c:936: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). nthreads = atoi(optarg); data/webfs-1.21+ds1/webfsd.c:1044: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(&ss,res->ai_addr,res->ai_addrlen); data/webfs-1.21+ds1/webfsd.c:1055:16: [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). tcp_port = atoi(serv); data/webfs-1.21+ds1/webfsd.c:1065:2: [2] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant string. strcpy(af.af_name,"httpready"); data/webfs-1.21+ds1/webfsd.c:1102:27: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if (NULL == (logfh = fopen(logfile,"a"))) data/webfs-1.21+ds1/webfsd.c:1111:19: [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 (-1 == (pid = open(pidfile,O_WRONLY | O_CREAT | O_EXCL, 0600))) { data/webfs-1.21+ds1/webfsd.c:1157:2: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(mypid,"%d",getpid()); data/webfs-1.21+ds1/cgi.c:34: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). line = malloc(strlen(name) + strlen(value) + 2); data/webfs-1.21+ds1/cgi.c:34: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). line = malloc(strlen(name) + strlen(value) + 2); data/webfs-1.21+ds1/cgi.c:63: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). l = strlen(env_wlist[j]); data/webfs-1.21+ds1/cgi.c:166: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). h = req->path + strlen(cgipath); data/webfs-1.21+ds1/cgi.c:201:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). rc = read(req->cgipipe, req->cgibuf+req->cgilen, MAX_HEADER-req->cgilen); data/webfs-1.21+ds1/cgi.c:229:15: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (0 == strlen(h)) data/webfs-1.21+ds1/ls.c:146:15: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int i,j,n=strlen((char *)path); data/webfs-1.21+ds1/ls.c:232: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). files[count] = malloc(strlen(file->d_name)+sizeof(struct myfile)); data/webfs-1.21+ds1/mime.c:67:11: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (1 != sscanf(line,"%63s%n",type,&len)) data/webfs-1.21+ds1/mime.c:71:15: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (1 != sscanf(line+off,"%7s%n",ext,&len)) data/webfs-1.21+ds1/request.c:32:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). rc = read(req->fd, req->hreq + req->hdata, MAX_HEADER - req->hdata); data/webfs-1.21+ds1/request.c:106:14: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (6 != sscanf(line,"%2d %3s %4d %2d:%2d:%2d GMT", data/webfs-1.21+ds1/request.c:110:11: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (6 != sscanf(line,"%2d-%3s-%2d %2d:%2d:%2d GMT", data/webfs-1.21+ds1/request.c:114:15: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (6 != sscanf(line,"%3s %2d %2d:%2d:%2d %4d", data/webfs-1.21+ds1/request.c:369:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(req->uri,filename,sizeof(req->uri)-1); data/webfs-1.21+ds1/request.c:472:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(req->hostname,server_host,sizeof(req->hostname)-1); data/webfs-1.21+ds1/request.c:476:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(req->hostname,server_host,sizeof(req->hostname)-1); data/webfs-1.21+ds1/request.c:491: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). 0 == strncmp(req->path,cgipath,strlen(cgipath))) { data/webfs-1.21+ds1/request.c:528:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(h+1, indexhtml, sizeof(filename) -len -1); data/webfs-1.21+ds1/request.c:601:6: [1] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant character. strcat(req->path,"/"); data/webfs-1.21+ds1/response.c:132:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). nread = read(in, buf, (bytes < BUFSIZE) ? bytes : BUFSIZE); data/webfs-1.21+ds1/response.c:222: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). req->lbody = strlen(req->body); data/webfs-1.21+ds1/response.c:249: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). req->lbody = strlen(req->body); data/webfs-1.21+ds1/response.c:545:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). rc = read(req->cgipipe, req->cgibuf, MAX_HEADER); data/webfs-1.21+ds1/ssl.c:116:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). rc = read(req->bfd, buf, len); data/webfs-1.21+ds1/ssl.c:130:15: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (num < strlen(password)+1) data/webfs-1.21+ds1/ssl.c:134: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). return(strlen(buf)); data/webfs-1.21+ds1/ssl.c:147: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 (cacert && strlen(cacert) && data/webfs-1.21+ds1/webfsd.c:230:26: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (0 == getuid() && strlen(user) > 0) { data/webfs-1.21+ds1/webfsd.c:236:26: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (0 == getuid() && strlen(group) > 0) { data/webfs-1.21+ds1/webfsd.c:271:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(group,gr->gr_name,16); data/webfs-1.21+ds1/webfsd.c:280:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(user,pw->pw_name,16); data/webfs-1.21+ds1/webfsd.c:425:10: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). mask = umask(0137); data/webfs-1.21+ds1/webfsd.c:430:10: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). (void) umask(mask); data/webfs-1.21+ds1/webfsd.c:531:9: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(5000); data/webfs-1.21+ds1/webfsd.c:884:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(server_host,optarg,64); data/webfs-1.21+ds1/webfsd.c:902:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(user,optarg,16); data/webfs-1.21+ds1/webfsd.c:905:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(group,optarg,16); data/webfs-1.21+ds1/webfsd.c:921: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). memset(optarg,'x',strlen(optarg)); data/webfs-1.21+ds1/webfsd.c:927: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). if (optarg[strlen(optarg)-1] == '/') { data/webfs-1.21+ds1/webfsd.c:930: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). cgipath = malloc(strlen(optarg)+2); data/webfs-1.21+ds1/webfsd.c:963: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). memset(optarg,'x',strlen(optarg)); data/webfs-1.21+ds1/webfsd.c:1100:20: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). mode_t mask = umask(0137); data/webfs-1.21+ds1/webfsd.c:1106:13: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). (void) umask(mask); data/webfs-1.21+ds1/webfsd.c:1158: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). write(pid,mypid,strlen(mypid)); ANALYSIS SUMMARY: Hits = 146 Lines analyzed = 3894 in approximately 0.13 seconds (29567 lines/second) Physical Source Lines of Code (SLOC) = 3293 Hits@level = [0] 95 [1] 45 [2] 73 [3] 2 [4] 26 [5] 0 Hits@level+ = [0+] 241 [1+] 146 [2+] 101 [3+] 28 [4+] 26 [5+] 0 Hits/KSLOC@level+ = [0+] 73.1855 [1+] 44.3365 [2+] 30.6711 [3+] 8.50288 [4+] 7.89554 [5+] 0 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.