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/dv4l-1.0/dv4l.c Examining data/dv4l-1.0/palettes.h Examining data/dv4l-1.0/scale.c Examining data/dv4l-1.0/util.h Examining data/dv4l-1.0/palettes.c Examining data/dv4l-1.0/scale.h Examining data/dv4l-1.0/normfile.c Examining data/dv4l-1.0/interdv4l.c Examining data/dv4l-1.0/util.c Examining data/dv4l-1.0/normfile.h FINAL RESULTS: data/dv4l-1.0/dv4l.c:395: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(devname, sz, VIDEODEV "%d", i); data/dv4l-1.0/dv4l.c:400: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(devname, sz, VIDEOV4LDEV "%d", i); data/dv4l-1.0/interdv4l.c:200:5: [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. int access(const char *path, int mode) data/dv4l-1.0/interdv4l.c:240:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(devname, devtmpl, i); data/dv4l-1.0/interdv4l.c:247:5: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(devname, devtmpl, 0); data/dv4l-1.0/interdv4l.c:266: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(vctx.vdevname, VIDEODEV); data/dv4l-1.0/interdv4l.c:272: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(vctx.vdevname, VIDEODEV); data/dv4l-1.0/interdv4l.c:278:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(vctx.vdevalt, VIDEOV4L "/video%d", m); data/dv4l-1.0/interdv4l.c:300: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(dir, name); data/dv4l-1.0/interdv4l.c:308: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(d, bname); data/dv4l-1.0/interdv4l.c:1179:3: [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(d->de.dirent.d_name, vctx.vdevbase); \ data/dv4l-1.0/normfile.c:251:2: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(d, path); data/dv4l-1.0/util.c:45: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(stderr, fmt, ap); data/dv4l-1.0/dv4l.c:669:13: [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. for(c = getopt_long(argc, argv, short_options, data/dv4l-1.0/dv4l.c:672:13: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. c = getopt_long(argc, argv, short_options, data/dv4l-1.0/interdv4l.c:263:8: [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(getenv("DV4L_NEWDEV") != NULL) { data/dv4l-1.0/interdv4l.c:371: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(const char *name) data/dv4l-1.0/interdv4l.c:381:13: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. dv4l_env = getenv("DV4L_VERBOSE"); data/dv4l-1.0/interdv4l.c:389:13: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. dv4l_env = getenv("DV4L_COLORCORR"); data/dv4l-1.0/interdv4l.c:392:13: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. dv4l_env = getenv("DV4L_RGBONLY"); data/dv4l-1.0/normfile.c:238:8: [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(path, normpath) != NULL) { data/dv4l-1.0/dv4l.c:82: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 *vfreeframes[NUM_BUFS]; data/dv4l-1.0/dv4l.c:369:10: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = open(devname, O_RDWR); data/dv4l-1.0/dv4l.c:663: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[80]; data/dv4l-1.0/dv4l.c:747: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[1024]; data/dv4l-1.0/dv4l.c:918: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[1024]; data/dv4l-1.0/dv4l.c:934:11: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). vfd = open(buf, O_RDWR); data/dv4l-1.0/dv4l.c:973:8: [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). vfd = open(buf, O_RDWR); data/dv4l-1.0/interdv4l.c:67: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 vdevname[PATH_MAX]; data/dv4l-1.0/interdv4l.c:68: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 vdevalt[PATH_MAX]; data/dv4l-1.0/interdv4l.c:69: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 vdevbase[PATH_MAX]; data/dv4l-1.0/interdv4l.c:98: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 resolved[PATH_MAX]; \ data/dv4l-1.0/interdv4l.c:275:6: [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(vctx.vdevalt, "/dev/video%d", m); data/dv4l-1.0/interdv4l.c:282:5: [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(vctx.vdevbase, "video%d", m); data/dv4l-1.0/interdv4l.c:291: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 dir[PATH_MAX]; data/dv4l-1.0/interdv4l.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 resolved[PATH_MAX]; data/dv4l-1.0/interdv4l.c:342: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(dp, dp + 1, (cp - dp) * sizeof cp); data/dv4l-1.0/interdv4l.c:360: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(envp2, envp, sz * sizeof *cp); data/dv4l-1.0/interdv4l.c:753:8: [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). MKOPEN(open) data/dv4l-1.0/interdv4l.c:1101: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 resolved[PATH_MAX]; data/dv4l-1.0/interdv4l.c:1272:6: [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(entry, de, sizeof *de); \ data/dv4l-1.0/interdv4l.c:1338: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[PATH_MAX]; \ data/dv4l-1.0/normfile.c:236: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[PATH_MAX]; data/dv4l-1.0/normfile.c:280: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[PATH_MAX]; data/dv4l-1.0/scale.c:119:6: [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, dst - dst_w * 3, dst_w * 3); data/dv4l-1.0/dv4l.c:374:16: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). slen = strlen(vc.name); data/dv4l-1.0/dv4l.c:680:21: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buf, optarg, sizeof buf); data/dv4l-1.0/dv4l.c:787:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). sz = read(vfd, buf, sizeof buf); data/dv4l-1.0/interdv4l.c:305: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). d = resolved + strlen(resolved); data/dv4l-1.0/interdv4l.c:799:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t read(int fd, void *buf, size_t count) data/dv4l-1.0/interdv4l.c:893:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(vcap->name, "DV4Linux dv1394 to V4L", sizeof(vcap->name)); data/dv4l-1.0/interdv4l.c:908:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(vchan->name, "DVCam", sizeof vchan->name); data/dv4l-1.0/interdv4l.c:980:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(fake_fd, vctx.vpmmap + vctx.vimgsz * frame, vctx.vimgsz); data/dv4l-1.0/normfile.c:248: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). d = buf + strlen(buf); ANALYSIS SUMMARY: Hits = 54 Lines analyzed = 3061 in approximately 0.12 seconds (26482 lines/second) Physical Source Lines of Code (SLOC) = 2493 Hits@level = [0] 18 [1] 9 [2] 24 [3] 8 [4] 13 [5] 0 Hits@level+ = [0+] 72 [1+] 54 [2+] 45 [3+] 21 [4+] 13 [5+] 0 Hits/KSLOC@level+ = [0+] 28.8809 [1+] 21.6606 [2+] 18.0505 [3+] 8.42359 [4+] 5.2146 [5+] 0 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.