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/spice-vdagent-0.20.0/src/vdagentd/virtio-port.h Examining data/spice-vdagent-0.20.0/src/vdagentd/uinput.h Examining data/spice-vdagent-0.20.0/src/vdagentd/console-kit.c Examining data/spice-vdagent-0.20.0/src/vdagentd/uinput.c Examining data/spice-vdagent-0.20.0/src/vdagentd/xorg-conf.h Examining data/spice-vdagent-0.20.0/src/vdagentd/session-info.h Examining data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c Examining data/spice-vdagent-0.20.0/src/vdagentd/xorg-conf.c Examining data/spice-vdagent-0.20.0/src/vdagentd/dummy-session-info.c Examining data/spice-vdagent-0.20.0/src/vdagentd/vdagentd.c Examining data/spice-vdagent-0.20.0/src/vdagentd/systemd-login.c Examining data/spice-vdagent-0.20.0/src/vdagent-connection.h Examining data/spice-vdagent-0.20.0/src/vdagentd-proto.h Examining data/spice-vdagent-0.20.0/src/vdagent/device-info.c Examining data/spice-vdagent-0.20.0/src/vdagent/file-xfers.c Examining data/spice-vdagent-0.20.0/src/vdagent/clipboard.h Examining data/spice-vdagent-0.20.0/src/vdagent/x11.h Examining data/spice-vdagent-0.20.0/src/vdagent/clipboard.c Examining data/spice-vdagent-0.20.0/src/vdagent/x11.c Examining data/spice-vdagent-0.20.0/src/vdagent/x11-randr.c Examining data/spice-vdagent-0.20.0/src/vdagent/x11-priv.h Examining data/spice-vdagent-0.20.0/src/vdagent/device-info.h Examining data/spice-vdagent-0.20.0/src/vdagent/file-xfers.h Examining data/spice-vdagent-0.20.0/src/vdagent/audio.c Examining data/spice-vdagent-0.20.0/src/vdagent/vdagent.c Examining data/spice-vdagent-0.20.0/src/vdagent/audio.h Examining data/spice-vdagent-0.20.0/src/vdagent-connection.c Examining data/spice-vdagent-0.20.0/src/vdagentd-proto-strings.h Examining data/spice-vdagent-0.20.0/src/udscs.c Examining data/spice-vdagent-0.20.0/src/udscs.h Examining data/spice-vdagent-0.20.0/tests/test-file-xfers.c Examining data/spice-vdagent-0.20.0/tests/test-device-info.c FINAL RESULTS: data/spice-vdagent-0.20.0/src/vdagentd/vdagentd.c:1219:13: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chmod(vdagentd_socket, 0666)) { data/spice-vdagent-0.20.0/src/vdagent/device-info.c:341:9: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf(dev_path, sizeof(dev_path), DRM_DEV_NAME, DRM_DIR_NAME, i); data/spice-vdagent-0.20.0/src/vdagent/vdagent.c:485:9: [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(orig_argv[0], orig_argv); data/spice-vdagent-0.20.0/src/vdagent/x11-priv.h:14:5: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_ERR, "%s: " format, \ data/spice-vdagent-0.20.0/src/vdagent/x11-priv.h:20:13: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_DEBUG, "%s: " format, \ data/spice-vdagent-0.20.0/src/vdagentd/vdagentd.c:342:9: [4] (format) syslog: If syslog's format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant format string for syslog. syslog(LOG_WARNING, msg, id); data/spice-vdagent-0.20.0/src/vdagentd/xorg-conf.c:35:13: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. r = fprintf(f, __VA_ARGS__); \ data/spice-vdagent-0.20.0/tests/test-file-xfers.c:40:25: [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. g_assert_cmpint(access(out, W_OK), ==, 0); data/spice-vdagent-0.20.0/tests/test-file-xfers.c:49:12: [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. assert(system("rm -rf test-dir && mkdir test-dir") == 0); data/spice-vdagent-0.20.0/tests/test-file-xfers.c:68:12: [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. assert(system("ln -s /proc/1 test-dir/baddir") == 0); data/spice-vdagent-0.20.0/tests/test-file-xfers.c:80:12: [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. assert(system("rm -rf test-dir") == 0); data/spice-vdagent-0.20.0/src/vdagent/device-info.c:357:13: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if (realpath(sys_path, device_link) == NULL) { data/spice-vdagent-0.20.0/src/udscs.c:148: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(buf, &header, sizeof(header)); data/spice-vdagent-0.20.0/src/udscs.c:149: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(buf + sizeof(header), data, size); data/spice-vdagent-0.20.0/src/vdagent/device-info.c:315: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). FILE *f = fopen(path, "r"); data/spice-vdagent-0.20.0/src/vdagent/device-info.c:337: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. char dev_path[64]; data/spice-vdagent-0.20.0/src/vdagent/device-info.c:350: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. char sys_path[64]; data/spice-vdagent-0.20.0/src/vdagent/device-info.c:356: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. char device_link[PATH_MAX]; data/spice-vdagent-0.20.0/src/vdagent/device-info.c:374: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. char id_path[150]; data/spice-vdagent-0.20.0/src/vdagent/device-info.c:412:18: [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 drm_fd = open(dev_path, O_RDWR); data/spice-vdagent-0.20.0/src/vdagent/device-info.c:470: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. char expected_name[100]; data/spice-vdagent-0.20.0/src/vdagent/file-xfers.c:199: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). file_fd = open(path, O_CREAT | O_WRONLY | O_EXCL, 0644); data/spice-vdagent-0.20.0/src/vdagent/vdagent.c:285: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]; data/spice-vdagent-0.20.0/src/vdagent/vdagent.c:314:13: [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 (open("/dev/null", O_RDWR) != STDIN_FILENO) { data/spice-vdagent-0.20.0/src/vdagent/x11-priv.h:49: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 *atom_names[16]; data/spice-vdagent-0.20.0/src/vdagent/x11-randr.c:213: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 name[20]; data/spice-vdagent-0.20.0/src/vdagent/x11-randr.c:324: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 modename[20]; data/spice-vdagent-0.20.0/src/vdagent/x11.c:753:13: [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(x11->clipboard_data + x11->clipboard_data_size, data, len); data/spice-vdagent-0.20.0/src/vdagent/x11.c:1245: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(x11->clipboard_agent_types[selection], types, data/spice-vdagent-0.20.0/src/vdagent/x11.c:1324:17: [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(x11->selection_req_data, data, size); data/spice-vdagent-0.20.0/src/vdagentd/uinput.c:119:18: [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). uinput->fd = open(uinput->devname, uinput->fake ? O_WRONLY : O_RDWR); data/spice-vdagent-0.20.0/src/vdagentd/vdagentd.c:339:9: [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(status->data, data, data_size); data/spice-vdagent-0.20.0/src/vdagentd/vdagentd.c:1076:13: [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 (open("/dev/null", O_RDWR) != STDIN_FILENO) { data/spice-vdagent-0.20.0/src/vdagentd/vdagentd.c:1087:19: [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). pidfile = fopen(pidfilename, "w"); data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:227: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(wbuf->buf + wbuf->write_pos, data, size); data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:275:9: [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((uint8_t *)&port->message_header + port->message_header_read, data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:307:13: [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(port->message_data + port->message_data_pos, data/spice-vdagent-0.20.0/src/vdagentd/xorg-conf.c:88:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f = fopen(xorg_conf, "w"); data/spice-vdagent-0.20.0/tests/test-file-xfers.c:56: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. char out_name[64]; data/spice-vdagent-0.20.0/tests/test-file-xfers.c:57:9: [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(out_name, "./test-dir/test (%d).txt", i); data/spice-vdagent-0.20.0/src/vdagent/device-info.c:166: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). if (strncmp(input, prefix, strlen(prefix)) != 0) { data/spice-vdagent-0.20.0/src/vdagent/device-info.c:170: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). char *pos = input + strlen(prefix); data/spice-vdagent-0.20.0/src/vdagent/file-xfers.c:211:72: [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 basename_len = extension != NULL ? extension - file_path : strlen(file_path); data/spice-vdagent-0.20.0/src/vdagent/vdagent.c:291:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(s, buf, sizeof(buf)) > 0) data/spice-vdagent-0.20.0/src/vdagent/x11-randr.c:330:23: [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). mode.nameLength = strlen(mode.name); data/spice-vdagent-0.20.0/src/vdagent/x11.c:318: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(100000); data/spice-vdagent-0.20.0/src/vdagentd/vdagentd.c:942: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). (uint8_t *)VERSION, strlen(VERSION) + 1); data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:264:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int avail, read, pos = 0; data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:272:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read > chunk_header->size) { data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:276:28: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). chunk_data, read); data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:277:38: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). port->message_header_read += read; data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:289:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). pos = read; data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:296:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (avail > read) { data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:303:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (avail < read) data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:306:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read) { data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:308:38: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). chunk_data + pos, read); data/spice-vdagent-0.20.0/src/vdagentd/virtio-port.c:309:39: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). port->message_data_pos += read; ANALYSIS SUMMARY: Hits = 57 Lines analyzed = 9615 in approximately 0.28 seconds (34471 lines/second) Physical Source Lines of Code (SLOC) = 7217 Hits@level = [0] 271 [1] 17 [2] 28 [3] 1 [4] 10 [5] 1 Hits@level+ = [0+] 328 [1+] 57 [2+] 40 [3+] 12 [4+] 11 [5+] 1 Hits/KSLOC@level+ = [0+] 45.4482 [1+] 7.89802 [2+] 5.54247 [3+] 1.66274 [4+] 1.52418 [5+] 0.138562 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.