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/pngquant-2.12.2/pngquant.c Examining data/pngquant-2.12.2/pngquant_opts.c Examining data/pngquant-2.12.2/pngquant_opts.h Examining data/pngquant-2.12.2/rwpng.c Examining data/pngquant-2.12.2/rwpng.h Examining data/pngquant-2.12.2/test/test.c FINAL RESULTS: data/pngquant-2.12.2/pngquant.c:74:30: [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. int required_space = vsnprintf(NULL, 0, fmt, va)+1; // +\0 data/pngquant-2.12.2/pngquant.c:83: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. vsnprintf(buf, required_space, fmt, va); data/pngquant-2.12.2/pngquant.c:131:5: [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(fd, "pngquant, %s, by Kornel Lesinski, Greg Roelofs.\n" data/pngquant-2.12.2/pngquant.c:550:9: [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(outname+x-4, newext); data/pngquant-2.12.2/pngquant.c:552:9: [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(outname+x, newext); data/pngquant-2.12.2/pngquant.c:564: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(outname, basename); data/pngquant-2.12.2/pngquant_opts.c:86: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. opt = getopt_long(argc, argv, "Vvqfhs:Q:o:", long_options, NULL); data/pngquant-2.12.2/pngquant.c:80: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 buf[required_space]; data/pngquant-2.12.2/pngquant.c:102: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[LOG_BUFFER_SIZE]; data/pngquant-2.12.2/pngquant.c:122: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(&log->buf[log->buf_used], msg, len); data/pngquant-2.12.2/pngquant.c:530:21: [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 *outfile = fopen(outname, "rb"); data/pngquant-2.12.2/pngquant.c:565:5: [2] (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). Risk is low because the source is a constant string. strcpy(outname+x, ".tmp"); data/pngquant-2.12.2/pngquant.c:615:24: [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 ((outfile = fopen(tempname, "wb")) == NULL) { data/pngquant-2.12.2/pngquant.c:669: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). } else if ((infile = fopen(filename, "rb")) == NULL) { data/pngquant-2.12.2/pngquant_opts.c:132:34: [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). options->speed = atoi(optarg); data/pngquant-2.12.2/pngquant_opts.c:140:38: [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). options->posterize = atoi(optarg); data/pngquant-2.12.2/rwpng.c:144: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(chunk->name, in_chunk->name, 5); data/pngquant-2.12.2/rwpng.c:149: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(chunk->data, in_chunk->data, in_chunk->size); data/pngquant-2.12.2/rwpng.c:559: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(pngchunk.name, chunk->name, 5); data/pngquant-2.12.2/rwpng.h:47: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 name[5]; data/pngquant-2.12.2/test/test.c:30: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 dummy[4] = {0}; data/pngquant-2.12.2/test/test.c:60:20: [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 dummy1[4] = {255,0,255,255}; data/pngquant-2.12.2/test/test.c:67:20: [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 dummy2[4] = {0,0,0,0}; data/pngquant-2.12.2/test/test.c:101: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 dummy[4] = {0}; data/pngquant-2.12.2/test/test.c:123: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 dummy[4] = {0}; data/pngquant-2.12.2/test/test.c:153: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[1]; data/pngquant-2.12.2/pngquant.c:118:15: [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 = strlen(msg); data/pngquant-2.12.2/pngquant.c:543: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). size_t x = strlen(filename); data/pngquant-2.12.2/pngquant.c:545: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). char* outname = malloc(x+4+strlen(newext)+1); data/pngquant-2.12.2/pngquant.c:548:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(outname, filename, x); data/pngquant-2.12.2/pngquant.c:559: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). size_t x = strlen(basename); data/pngquant-2.12.2/rwpng.c:79:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (!read) { data/pngquant-2.12.2/rwpng.c:82:30: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read_data->bytes_read += read; data/pngquant-2.12.2/test/test.c:12: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). assert(strlen(message)); ANALYSIS SUMMARY: Hits = 34 Lines analyzed = 1877 in approximately 0.06 seconds (30297 lines/second) Physical Source Lines of Code (SLOC) = 1398 Hits@level = [0] 19 [1] 8 [2] 19 [3] 1 [4] 6 [5] 0 Hits@level+ = [0+] 53 [1+] 34 [2+] 26 [3+] 7 [4+] 6 [5+] 0 Hits/KSLOC@level+ = [0+] 37.9113 [1+] 24.3205 [2+] 18.598 [3+] 5.00715 [4+] 4.29185 [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.