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/ptouch-driver-1.5.1/ptexplain.c Examining data/ptouch-driver-1.5.1/rastertoptch.c FINAL RESULTS: data/ptouch-driver-1.5.1/ptexplain.c:72:25: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__ ((format (printf, 2, 3))) data/ptouch-driver-1.5.1/ptexplain.c:81:3: [4] (format) vprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vprintf (fmt, ap); data/ptouch-driver-1.5.1/ptexplain.c:132:9: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf (" %sESC%s" + first, data/ptouch-driver-1.5.1/ptexplain.c:137:9: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf (" %s^Z%s" + first, data/ptouch-driver-1.5.1/ptexplain.c:143:11: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf (" %s%c%s" + first, data/ptouch-driver-1.5.1/ptexplain.c:146:4: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf (" %s%02x%s" + first, data/ptouch-driver-1.5.1/ptexplain.c:151:7: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf (" %s%02x%s" + first, data/ptouch-driver-1.5.1/ptexplain.c:157:5: [4] (format) vprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vprintf (fmt, *ap); data/ptouch-driver-1.5.1/ptexplain.c:163:25: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__ ((format (printf, 1, 2))) data/ptouch-driver-1.5.1/ptexplain.c:174:25: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__ ((format (printf, 1, 2))) data/ptouch-driver-1.5.1/ptexplain.c:454:25: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__ ((format (printf, 3, 4))) data/ptouch-driver-1.5.1/ptexplain.c:461:9: [4] (format) vsnprintf: 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. len = vsnprintf (*str, end - *str - 1, fmt, ap); data/ptouch-driver-1.5.1/ptexplain.c:814:14: [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. char c = getopt_long (argc, argv, options, long_options, NULL); data/ptouch-driver-1.5.1/rastertoptch.c:1592: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. int c = getopt_long (argc, argv, "hi:o:", long_options, NULL); data/ptouch-driver-1.5.1/ptexplain.c:87: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. unsigned char type[COMMAND_STACK_SIZE]; data/ptouch-driver-1.5.1/ptexplain.c:88: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. unsigned char data[COMMAND_STACK_SIZE]; data/ptouch-driver-1.5.1/ptexplain.c:195:7: [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 text[HEX_CHUNK_SIZE + 1]; data/ptouch-driver-1.5.1/ptexplain.c:305: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 (image.buffer + image.size, row, image.row_size); data/ptouch-driver-1.5.1/ptexplain.c:396:8: [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, "wb"); data/ptouch-driver-1.5.1/ptexplain.c:473: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. static char buffer[256]; data/ptouch-driver-1.5.1/ptexplain.c:627: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 info[256]; data/ptouch-driver-1.5.1/ptexplain.c:630: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(strchr(info, 0), " kind=0x%02x", d[1]); data/ptouch-driver-1.5.1/ptexplain.c:632: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(strchr(info, 0), " width=%u", d[2]); data/ptouch-driver-1.5.1/ptexplain.c:634: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(strchr(info, 0), " length=%u", d[3]); data/ptouch-driver-1.5.1/ptexplain.c:635:4: [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(strchr(info, 0), " lines=%u", data/ptouch-driver-1.5.1/ptexplain.c:639: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(strchr(info, 0), " page=first"); data/ptouch-driver-1.5.1/ptexplain.c:642: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(strchr(info, 0), " page=non-first"); data/ptouch-driver-1.5.1/ptexplain.c:645: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(strchr(info, 0), " page=last"); data/ptouch-driver-1.5.1/ptexplain.c:856:14: [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 fd = open (filename, O_RDONLY); data/ptouch-driver-1.5.1/rastertoptch.c:328:3: [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[64]; data/ptouch-driver-1.5.1/rastertoptch.c:890:16: [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 unsigned char mirror [0x100] = { data/ptouch-driver-1.5.1/rastertoptch.c:1174: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 (rle_next, mix_start, mix_len); \ data/ptouch-driver-1.5.1/rastertoptch.c:1624:14: [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 fd = open (input_filename, O_RDONLY); data/ptouch-driver-1.5.1/rastertoptch.c:1634:14: [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 fd = open (output_filename, O_CREAT | O_WRONLY | O_TRUNC, 0666); data/ptouch-driver-1.5.1/ptexplain.c:193:13: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c = getchar (); data/ptouch-driver-1.5.1/ptexplain.c:226:7: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = getchar (); data/ptouch-driver-1.5.1/ptexplain.c:551:19: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((c = getchar ()) == 0) ANALYSIS SUMMARY: Hits = 37 Lines analyzed = 2528 in approximately 0.09 seconds (26938 lines/second) Physical Source Lines of Code (SLOC) = 1832 Hits@level = [0] 41 [1] 3 [2] 20 [3] 2 [4] 12 [5] 0 Hits@level+ = [0+] 78 [1+] 37 [2+] 34 [3+] 14 [4+] 12 [5+] 0 Hits/KSLOC@level+ = [0+] 42.5764 [1+] 20.1965 [2+] 18.559 [3+] 7.64192 [4+] 6.55022 [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.