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/directvnc-0.7.8/src/tight.c Examining data/directvnc-0.7.8/src/sockets.c Examining data/directvnc-0.7.8/src/jpeg.h Examining data/directvnc-0.7.8/src/getopt1.c Examining data/directvnc-0.7.8/src/directvnc.h Examining data/directvnc-0.7.8/src/debug.h Examining data/directvnc-0.7.8/src/vncauth.c Examining data/directvnc-0.7.8/src/d3des.h Examining data/directvnc-0.7.8/src/cursor.c Examining data/directvnc-0.7.8/src/vncauth.h Examining data/directvnc-0.7.8/src/jpeg.c Examining data/directvnc-0.7.8/src/keysym.h Examining data/directvnc-0.7.8/src/main.c Examining data/directvnc-0.7.8/src/getopt.c Examining data/directvnc-0.7.8/src/rfb.c Examining data/directvnc-0.7.8/src/args.c Examining data/directvnc-0.7.8/src/getopt.h Examining data/directvnc-0.7.8/src/dfb.c Examining data/directvnc-0.7.8/src/d3des.c Examining data/directvnc-0.7.8/src/rfbproto.h Examining data/directvnc-0.7.8/src/tight.h Examining data/directvnc-0.7.8/src/modmap.c FINAL RESULTS: data/directvnc-0.7.8/src/vncauth.c:58:5: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod(fname, S_IRUSR|S_IWUSR); data/directvnc-0.7.8/src/modmap.c:202:5: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. sscanf(cp,"%s %c %x %x %x %x", kkbuf, &me.keycode, &me.base, &me.shift, &me.mode, &me.modshift); data/directvnc-0.7.8/src/rfb.c:124:4: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(msg, rfbProtocolVersionFormat, data/directvnc-0.7.8/src/rfb.c:159:44: [4] (misc) getpass: This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data (e.g., /dev/tty, stdin, stderr, etc.). In addition, some implementations overflow buffers. (CWE-676, CWE-120, CWE-20). Make the specific calls to do exactly what you want. If you continue to use it, or write your own, be sure to zero the password as soon as possible to avoid leaving the cleartext password visible in the process' address space. if (!opt.password) opt.password = getpass("Password: "); data/directvnc-0.7.8/src/getopt.c:208:7: [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. char *getenv(); data/directvnc-0.7.8/src/getopt.c:400:22: [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/directvnc-0.7.8/src/getopt.c:965: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/directvnc-0.7.8/src/getopt.c:993: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/directvnc-0.7.8/src/getopt.h:106:15: [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/directvnc-0.7.8/src/getopt.h:111:15: [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/directvnc-0.7.8/src/getopt.h:114:15: [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/directvnc-0.7.8/src/getopt.h:126:15: [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/directvnc-0.7.8/src/getopt.h:127:15: [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/directvnc-0.7.8/src/getopt1.c:69: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/directvnc-0.7.8/src/getopt1.c:125:10: [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, "abc:d:0123456789", long_options, data/directvnc-0.7.8/src/vncauth.c:131:5: [3] (random) srandom: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srandom(seed); data/directvnc-0.7.8/src/vncauth.c:133:29: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. bytes[i] = (unsigned char)(random() & 255); data/directvnc-0.7.8/src/args.c:47:14: [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). opt.port = atoi(buf); data/directvnc-0.7.8/src/args.c:150:15: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). intarg = atoi(optarg); data/directvnc-0.7.8/src/args.c:173:22: [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). opt.poll_freq = atoi(optarg); data/directvnc-0.7.8/src/args.c:194:15: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). intarg = atoi(optarg); data/directvnc-0.7.8/src/args.c:203:15: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). intarg = atoi(optarg); data/directvnc-0.7.8/src/d3des.c:59:17: [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 unsigned char pc1[56] = { data/directvnc-0.7.8/src/d3des.c:65:17: [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 unsigned char totrot[16] = { data/directvnc-0.7.8/src/d3des.c:68:17: [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 unsigned char pc2[48] = { data/directvnc-0.7.8/src/d3des.c:79: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. unsigned char pc1m[56], pcr[56]; data/directvnc-0.7.8/src/dfb.c:140: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 (dst, data, src_pitch); data/directvnc-0.7.8/src/directvnc.h:45: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 buffer[BUFFER_SIZE]; data/directvnc-0.7.8/src/modmap.c:135: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 buffer[BUFSIZ]; data/directvnc-0.7.8/src/modmap.c:142: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). fp = fopen (filename, "r"); data/directvnc-0.7.8/src/modmap.c:171: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 kkbuf[10]; data/directvnc-0.7.8/src/rfb.c:72: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.sin_addr.s_addr, he->h_addr, he->h_length); data/directvnc-0.7.8/src/rfb.c:709: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(&foo16, data, 2); data/directvnc-0.7.8/src/rfbproto.h:161: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. typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */ data/directvnc-0.7.8/src/sockets.c:42: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 buf[BUF_SIZE]; data/directvnc-0.7.8/src/sockets.c:66: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(out, bufoutptr, n); data/directvnc-0.7.8/src/sockets.c:72: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(out, bufoutptr, buffered); data/directvnc-0.7.8/src/sockets.c:118: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(out, bufoutptr, n); data/directvnc-0.7.8/src/sockets.c:243: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 c, str[17]; data/directvnc-0.7.8/src/tight.c:50: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 zlib_buffer[ZLIB_BUFFER_SIZE]; data/directvnc-0.7.8/src/tight.c:61: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 tightPalette[256*4]; data/directvnc-0.7.8/src/tight.c:261: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(buffer, &buffer[numRows * rowSize], extraBytes); data/directvnc-0.7.8/src/tight.c:299: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 (dst, src, numRows * rectWidth * (opt.client.bpp / 8)); data/directvnc-0.7.8/src/tight.c:361: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(thatRow, thisRow, rectWidth * 3 * sizeof(CARD16)); data/directvnc-0.7.8/src/vncauth.c:41:10: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char fixedkey[8] = {23,82,107,6,35,78,88,7}; data/directvnc-0.7.8/src/vncauth.c:54: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. unsigned char encryptedPasswd[8]; data/directvnc-0.7.8/src/vncauth.c:56: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(fname,"w")) == NULL) return 1; data/directvnc-0.7.8/src/vncauth.c:98: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(fname,"r")) == NULL) return NULL; data/directvnc-0.7.8/src/vncauth.c:145: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. unsigned char key[8]; data/directvnc-0.7.8/src/getopt.c:232: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/directvnc-0.7.8/src/getopt.c:431: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). int len = nonoption_flags_max_len = strlen(orig_str); data/directvnc-0.7.8/src/getopt.c:655:32: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). (unsigned int) strlen(p->name)) data/directvnc-0.7.8/src/getopt.c:679:22: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). nextchar += strlen(nextchar); data/directvnc-0.7.8/src/getopt.c:711: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). nextchar += strlen(nextchar); data/directvnc-0.7.8/src/getopt.c:726: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). nextchar += strlen(nextchar); data/directvnc-0.7.8/src/getopt.c:731:22: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). nextchar += strlen(nextchar); data/directvnc-0.7.8/src/getopt.c:840: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). if ((unsigned int) (nameend - nextchar) == strlen(p->name)) data/directvnc-0.7.8/src/getopt.c:863: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). nextchar += strlen(nextchar); data/directvnc-0.7.8/src/getopt.c:882: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). nextchar += strlen(nextchar); data/directvnc-0.7.8/src/getopt.c:896: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). nextchar += strlen(nextchar); data/directvnc-0.7.8/src/getopt.c:900: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). nextchar += strlen(nextchar); data/directvnc-0.7.8/src/modmap.c:174: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 (buffer); data/directvnc-0.7.8/src/sockets.c:84:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int i = read(sock, buf + buffered, BUF_SIZE - buffered); data/directvnc-0.7.8/src/sockets.c:93:19: [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(10000); data/directvnc-0.7.8/src/sockets.c:129:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int i = read(sock, out, n); data/directvnc-0.7.8/src/sockets.c:138:19: [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(10000); data/directvnc-0.7.8/src/vncauth.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). if (i < strlen(passwd)) { data/directvnc-0.7.8/src/vncauth.c:101:7: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch = getc(fp); data/directvnc-0.7.8/src/vncauth.c:151: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). if (i < strlen(passwd)) { ANALYSIS SUMMARY: Hits = 69 Lines analyzed = 6578 in approximately 0.21 seconds (31190 lines/second) Physical Source Lines of Code (SLOC) = 4026 Hits@level = [0] 101 [1] 20 [2] 32 [3] 13 [4] 3 [5] 1 Hits@level+ = [0+] 170 [1+] 69 [2+] 49 [3+] 17 [4+] 4 [5+] 1 Hits/KSLOC@level+ = [0+] 42.2255 [1+] 17.1386 [2+] 12.1709 [3+] 4.22255 [4+] 0.993542 [5+] 0.248385 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.