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/pngcrush-1.8.13/cexcept.h Examining data/pngcrush-1.8.13/pngcrush.c FINAL RESULTS: data/pngcrush-1.8.13/pngcrush.c:4758:17: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(in_string, inname, STR_BUF_SIZE-1); data/pngcrush-1.8.13/pngcrush.c:4760:17: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(in_string, outname, STR_BUF_SIZE-1); data/pngcrush-1.8.13/pngcrush.c:4782:17: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(in_extension, ++dot, STR_BUF_SIZE - 1); data/pngcrush-1.8.13/pngcrush.c:4785:13: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(out_string, extension, STR_BUF_SIZE - 1); data/pngcrush-1.8.13/pngcrush.c:480:45: [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. Show if pngcrush is built with bundled or system libpng and zlib. data/pngcrush-1.8.13/pngcrush.c:649:53: [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. Multiplied rowbytes by 8/bit_depth when using the system library because data/pngcrush-1.8.13/pngcrush.c:744:5: [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. system <zlib.h>. data/pngcrush-1.8.13/pngcrush.c:803:30: [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. Removed comments about the system library having to be libpng14 or earlier. data/pngcrush-1.8.13/pngcrush.c:879:58: [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. Removed the call to png_read_transform_info() when the system libpng data/pngcrush-1.8.13/pngcrush.c:880:46: [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. is being used, so it can be built with a system libpng. data/pngcrush-1.8.13/pngcrush.c:886:14: [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. with the system libpng15. data/pngcrush-1.8.13/pngcrush.c:916:7: [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. a system libpng-1.5.x. data/pngcrush-1.8.13/pngcrush.c:948:44: [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. and later. A warning about deprecated access to png_ptr->zstream is data/pngcrush-1.8.13/pngcrush.c:966:37: [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. Added check for "verbose" on some printf statements. data/pngcrush-1.8.13/pngcrush.c:1163:36: [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. Write 500K IDAT chunks even when system libpng is being used. data/pngcrush-1.8.13/pngcrush.c:1276:18: [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. Removed direct access to the png structure when possible, and isolated data/pngcrush-1.8.13/pngcrush.c:2091:41: [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. #define P0 if(last_trial && verbose > 0)printf data/pngcrush-1.8.13/pngcrush.c:2092:27: [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. #define P1 if(verbose > 1)printf data/pngcrush-1.8.13/pngcrush.c:2093:27: [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. #define P2 if(verbose > 2)printf data/pngcrush-1.8.13/pngcrush.c:4474: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. fprintf(STDERR, PNGCRUSH_VERSION); data/pngcrush-1.8.13/pngcrush.c:4476: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. fprintf(STDERR, PNG_LIBPNG_VER_STRING); data/pngcrush-1.8.13/pngcrush.c:4478: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. fprintf(STDERR, ZLIB_VERSION); data/pngcrush-1.8.13/pngcrush.c:4688:13: [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(out_string, directory_name); data/pngcrush-1.8.13/pngcrush.c:4703:13: [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(in_string, inname); data/pngcrush-1.8.13/pngcrush.c:4731:13: [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(out_string+outlen, op); data/pngcrush-1.8.13/pngcrush.c:9275: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. fprintf(STDERR, pngcrush_usage[j], progname); /* special case */ data/pngcrush-1.8.13/pngcrush.c:754:5: [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). open an output file. data/pngcrush-1.8.13/pngcrush.c:792:58: [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). Removed FOPEN of fpout except for the last trial. The open files caused data/pngcrush-1.8.13/pngcrush.c:794:54: [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). 1024th compression trial) due to being unable to open the output file. data/pngcrush-1.8.13/pngcrush.c:1389:57: [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). Version 1.2.0: Removed registration requirement. Added open source data/pngcrush-1.8.13/pngcrush.c:1401:45: [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). Version 1.1.6: fixed bug with one file left open after each image is data/pngcrush-1.8.13/pngcrush.c:1834:25: [2] (buffer) CopyMemory: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. # define png_memcpy CopyMemory data/pngcrush-1.8.13/pngcrush.c:1838:25: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. # define png_memcpy memcpy data/pngcrush-1.8.13/pngcrush.c:2088:26: [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). #define FOPEN(file, how) fopen(file, how) data/pngcrush-1.8.13/pngcrush.c:2188: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 pplt_string[STR_BUF_SIZE]; data/pngcrush-1.8.13/pngcrush.c:2190: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 in_string[STR_BUF_SIZE]; data/pngcrush-1.8.13/pngcrush.c:2191: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 prog_string[STR_BUF_SIZE]; data/pngcrush-1.8.13/pngcrush.c:2192: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 out_string[STR_BUF_SIZE]; data/pngcrush-1.8.13/pngcrush.c:2193: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 in_extension[STR_BUF_SIZE]; data/pngcrush-1.8.13/pngcrush.c:2198: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 text_text[11*STR_BUF_SIZE+1]; /* It would be nice to png_malloc this but we data/pngcrush-1.8.13/pngcrush.c:2200: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 text_keyword[11*80+1]; data/pngcrush-1.8.13/pngcrush.c:2203: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 text_lang[881]; data/pngcrush-1.8.13/pngcrush.c:2204: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 text_lang_key[881]; data/pngcrush-1.8.13/pngcrush.c:2210: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 iccp_name[80]; data/pngcrush-1.8.13/pngcrush.c:2214: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[256]; data/pngcrush-1.8.13/pngcrush.c:3910: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. char number[16]; data/pngcrush-1.8.13/pngcrush.c:4201: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. char number[16]; data/pngcrush-1.8.13/pngcrush.c:6902:37: [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. png_memcpy((char *)ster[0].name, "sTER",5); data/pngcrush-1.8.13/pngcrush.c:6938:33: [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 *)unknowns[i].name); data/pngcrush-1.8.13/pngcrush.c:6944:45: [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. if (keep_chunk((char *)unknowns[i].name, argv)) data/pngcrush-1.8.13/pngcrush.c:422:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). the first read pass and while writing. data/pngcrush-1.8.13/pngcrush.c:604:35: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. i.e., the RGB sBIT values are equal to each other or the sBIT values are data/pngcrush-1.8.13/pngcrush.c:641:43: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). Reverted to libpng-1.5.15 to be able to read old PNG files with TOO FAR data/pngcrush-1.8.13/pngcrush.c:766:43: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). reads to not go through the alternate read function. Also always set this data/pngcrush-1.8.13/pngcrush.c:883:29: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). pngcrush-1.7.18 failed to read interlaced PNGs. Reverted the change data/pngcrush-1.8.13/pngcrush.c:1367:69: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). "#ifdefed" out more unused code (weighted filters and progressive read; data/pngcrush-1.8.13/pngcrush.c:2847:28: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). keystroke = (char) getc(stdin); data/pngcrush-1.8.13/pngcrush.c:3620:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(prog_string, argv[0], STR_BUF_SIZE); data/pngcrush-1.8.13/pngcrush.c:3913:30: [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 length = strlen(argv[i]); data/pngcrush-1.8.13/pngcrush.c:3967:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(iccp_name, argv[i], 80); data/pngcrush-1.8.13/pngcrush.c:4158:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(pplt_string, argv[i], STR_BUF_SIZE); data/pngcrush-1.8.13/pngcrush.c:4204:30: [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 length = strlen(argv[i]); data/pngcrush-1.8.13/pngcrush.c:4341:17: [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(argv[i + 2]) < 80 && data/pngcrush-1.8.13/pngcrush.c:4342:17: [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). strlen(argv[i + 3]) < STR_BUF_SIZE && data/pngcrush-1.8.13/pngcrush.c:4373:17: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(&text_keyword[text_inputs * 80], argv[++i], data/pngcrush-1.8.13/pngcrush.c:4388:21: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(&text_lang[text_inputs * 80], argv[++i], 80); data/pngcrush-1.8.13/pngcrush.c:4391:21: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(&text_lang_key[text_inputs * 80], argv[++i], 80); data/pngcrush-1.8.13/pngcrush.c:4395:17: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(&text_text[text_inputs * STR_BUF_SIZE], argv[++i], data/pngcrush-1.8.13/pngcrush.c:4679: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). outlen = strlen(directory_name); data/pngcrush-1.8.13/pngcrush.c:4696:21: [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). inlen = strlen(inname); data/pngcrush-1.8.13/pngcrush.c:4789: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). if ((outname[strlen(outname) - 4] == 'p') && data/pngcrush-1.8.13/pngcrush.c:4790: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). (outname[strlen(outname) - 3] == 'p') && data/pngcrush-1.8.13/pngcrush.c:4791: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). (outname[strlen(outname) - 2] == 'n') && data/pngcrush-1.8.13/pngcrush.c:4792: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). (outname[strlen(outname) - 1] == 'g')) data/pngcrush-1.8.13/pngcrush.c:4801: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). if ((outname[strlen(outname) - 4] == 'a') && data/pngcrush-1.8.13/pngcrush.c:4802: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). (outname[strlen(outname) - 3] == 'p') && data/pngcrush-1.8.13/pngcrush.c:4803: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). (outname[strlen(outname) - 2] == 'n') && data/pngcrush-1.8.13/pngcrush.c:4804: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). (outname[strlen(outname) - 1] == 'g')) data/pngcrush-1.8.13/pngcrush.c:7045: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). if (outname[strlen(outname) - 3] == 'p') ANALYSIS SUMMARY: Hits = 79 Lines analyzed = 9569 in approximately 0.27 seconds (34883 lines/second) Physical Source Lines of Code (SLOC) = 7371 Hits@level = [0] 230 [1] 29 [2] 24 [3] 0 [4] 22 [5] 4 Hits@level+ = [0+] 309 [1+] 79 [2+] 50 [3+] 26 [4+] 26 [5+] 4 Hits/KSLOC@level+ = [0+] 41.921 [1+] 10.7177 [2+] 6.78334 [3+] 3.52734 [4+] 3.52734 [5+] 0.542667 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.