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/tsocks-1.8beta5+ds1/saveme.c Examining data/tsocks-1.8beta5+ds1/tsocks.h Examining data/tsocks-1.8beta5+ds1/inspectsocks.c Examining data/tsocks-1.8beta5+ds1/common.h Examining data/tsocks-1.8beta5+ds1/validateconf.c Examining data/tsocks-1.8beta5+ds1/common.c Examining data/tsocks-1.8beta5+ds1/acconfig.h Examining data/tsocks-1.8beta5+ds1/parser.h Examining data/tsocks-1.8beta5+ds1/parser.c Examining data/tsocks-1.8beta5+ds1/tsocks.c FINAL RESULTS: data/tsocks-1.8beta5+ds1/common.c:126: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(logfile, fmt, ap); data/tsocks-1.8beta5+ds1/parser.c:55:6: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(line, R_OK)) { data/tsocks-1.8beta5+ds1/parser.c:655: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). strcpy(ipbuf, inet_ntoa(net->localip)); data/tsocks-1.8beta5+ds1/tsocks.c:970: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((char *) thisreq + sizeof(struct sockreq), data/tsocks-1.8beta5+ds1/tsocks.c:156:15: [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 ((env = getenv("TSOCKS_DEBUG"))) data/tsocks-1.8beta5+ds1/tsocks.c:158:16: [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 (((env = getenv("TSOCKS_DEBUG_FILE"))) && !suid) data/tsocks-1.8beta5+ds1/tsocks.c:177:18: [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. conffile = getenv("TSOCKS_CONF_FILE"); data/tsocks-1.8beta5+ds1/tsocks.c:1091: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. ((uname = getenv("TSOCKS_USERNAME")) == NULL) && data/tsocks-1.8beta5+ds1/tsocks.c:1101:17: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. if (((upass = getenv("TSOCKS_PASSWORD")) == NULL) && data/tsocks-1.8beta5+ds1/common.c:23: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 logfilename[256]; /* Name of file to which log messages should data/tsocks-1.8beta5+ds1/common.c:88: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 timestring[20]; data/tsocks-1.8beta5+ds1/common.c:96:20: [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). logfile = fopen(logfilename, "a"); data/tsocks-1.8beta5+ds1/inspectsocks.c:48: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 req[9]; data/tsocks-1.8beta5+ds1/inspectsocks.c:49: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 resp[100]; data/tsocks-1.8beta5+ds1/parser.c:69: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[MAXLINE]; data/tsocks-1.8beta5+ds1/parser.c:88:14: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if ((conf = fopen(filename, "r")) == NULL) { data/tsocks-1.8beta5+ds1/parser.c:142: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 *words[10]; data/tsocks-1.8beta5+ds1/parser.c:143:9: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char savedline[MAXLINE]; data/tsocks-1.8beta5+ds1/parser.c:540:9: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char buf[200]; data/tsocks-1.8beta5+ds1/parser.c:644: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 ipbuf[64]; data/tsocks-1.8beta5+ds1/tsocks.c:157:18: [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). loglevel = atoi(env); data/tsocks-1.8beta5+ds1/tsocks.c:532: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(readfds, &myreadfds, sizeof(myreadfds)); data/tsocks-1.8beta5+ds1/tsocks.c:534: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(writefds, &mywritefds, sizeof(mywritefds)); data/tsocks-1.8beta5+ds1/tsocks.c:536: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(exceptfds, &myexceptfds, sizeof(myexceptfds)); data/tsocks-1.8beta5+ds1/tsocks.c:783:4: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(newconn->connaddr), connaddr, sizeof(newconn->connaddr)); data/tsocks-1.8beta5+ds1/tsocks.c:784:4: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(newconn->serveraddr), serveraddr, sizeof(newconn->serveraddr)); data/tsocks-1.8beta5+ds1/tsocks.c:989:4: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(conn->buffer, verstring, sizeof(verstring)); data/tsocks-1.8beta5+ds1/tsocks.c:1006:4: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(conn->buffer, constring, sizeof(constring)); data/tsocks-1.8beta5+ds1/tsocks.c:1008:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&conn->buffer[conn->datalen], &(conn->connaddr.sin_addr.s_addr), data/tsocks-1.8beta5+ds1/tsocks.c:1011:2: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&conn->buffer[conn->datalen], &(conn->connaddr.sin_port), sizeof(conn->connaddr.sin_port)); data/tsocks-1.8beta5+ds1/tsocks.c:1123: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(&(conn->buffer[conn->datalen]), uname, strlen(uname)); data/tsocks-1.8beta5+ds1/tsocks.c:1127: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(&(conn->buffer[conn->datalen]), upass, strlen(upass)); data/tsocks-1.8beta5+ds1/tsocks.h:55: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 buffer[1024]; data/tsocks-1.8beta5+ds1/common.c:76:7: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(logfilename, filename, sizeof(logfilename)); data/tsocks-1.8beta5+ds1/parser.c:57:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(line, CONF_FILE, MAXLINE - 1); data/tsocks-1.8beta5+ds1/parser.c:100: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(line) > 0) data/tsocks-1.8beta5+ds1/parser.c:101: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). line[strlen(line) - 1] = '\0'; data/tsocks-1.8beta5+ds1/parser.c:147:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(savedline, line, MAXLINE - 1); data/tsocks-1.8beta5+ds1/parser.c:544:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buf, value, sizeof(buf) - 1); data/tsocks-1.8beta5+ds1/parser.c:698: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 (len == strlen(*text)) { data/tsocks-1.8beta5+ds1/tsocks.c:956:40: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). (user == NULL ? 0 : strlen(user->pw_name)) + 1; data/tsocks-1.8beta5+ds1/tsocks.c:1111: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). if ((3 + strlen(uname) + strlen(upass)) >= sizeof(conn->buffer)) { data/tsocks-1.8beta5+ds1/tsocks.c:1111: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 ((3 + strlen(uname) + strlen(upass)) >= sizeof(conn->buffer)) { data/tsocks-1.8beta5+ds1/tsocks.c:1121: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). conn->buffer[conn->datalen] = (int8_t) strlen(uname); data/tsocks-1.8beta5+ds1/tsocks.c:1123:49: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). memcpy(&(conn->buffer[conn->datalen]), uname, strlen(uname)); data/tsocks-1.8beta5+ds1/tsocks.c:1124: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). conn->datalen = conn->datalen + strlen(uname); data/tsocks-1.8beta5+ds1/tsocks.c:1125: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). conn->buffer[conn->datalen] = (int8_t) strlen(upass); data/tsocks-1.8beta5+ds1/tsocks.c:1127:49: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). memcpy(&(conn->buffer[conn->datalen]), upass, strlen(upass)); data/tsocks-1.8beta5+ds1/tsocks.c:1128: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). conn->datalen = conn->datalen + strlen(upass); ANALYSIS SUMMARY: Hits = 49 Lines analyzed = 2770 in approximately 0.09 seconds (30192 lines/second) Physical Source Lines of Code (SLOC) = 1960 Hits@level = [0] 43 [1] 16 [2] 24 [3] 5 [4] 4 [5] 0 Hits@level+ = [0+] 92 [1+] 49 [2+] 33 [3+] 9 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 46.9388 [1+] 25 [2+] 16.8367 [3+] 4.59184 [4+] 2.04082 [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.