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/catimg-2.7.0/src/catimg.c Examining data/catimg-2.7.0/src/khash.h Examining data/catimg-2.7.0/src/sh_color.c Examining data/catimg-2.7.0/src/sh_color.h Examining data/catimg-2.7.0/src/sh_image.c Examining data/catimg-2.7.0/src/sh_image.h Examining data/catimg-2.7.0/src/sh_utils.c Examining data/catimg-2.7.0/src/sh_utils.h Examining data/catimg-2.7.0/src/stb_image.h FINAL RESULTS: data/catimg-2.7.0/src/catimg.c:87:21: [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(ERR_WIDTH_OR_HEIGHT); data/catimg-2.7.0/src/catimg.c:88:21: [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(USAGE); data/catimg-2.7.0/src/catimg.c:97:21: [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(ERR_WIDTH_OR_HEIGHT); data/catimg-2.7.0/src/catimg.c:98:21: [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(USAGE); data/catimg-2.7.0/src/catimg.c:110:17: [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(USAGE); data/catimg-2.7.0/src/catimg.c:120:17: [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(USAGE); data/catimg-2.7.0/src/catimg.c:128: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(USAGE); data/catimg-2.7.0/src/catimg.c:169:9: [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("clear"); data/catimg-2.7.0/src/catimg.c:42:5: [3] (buffer) getopt: 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 getopt(int argc, char * const argv[], const char *optstring); data/catimg-2.7.0/src/catimg.c:56:26: [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. const char* LC_ALL = getenv("LC_ALL"); data/catimg-2.7.0/src/catimg.c:57:24: [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. const char* LANG = getenv("LANG"); data/catimg-2.7.0/src/catimg.c:58:28: [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. const char* LC_CTYPE = getenv("LC_CTYPE"); data/catimg-2.7.0/src/catimg.c:81:17: [3] (buffer) getopt: 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. while ((c = getopt (argc, argv, "H:w:l:r:hct")) != -1) data/catimg-2.7.0/src/sh_image.c:46:27: [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(prev->data, temp, stride); data/catimg-2.7.0/src/sh_image.c:74:33: [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(p, gr->data, size); data/catimg-2.7.0/src/sh_utils.c:58: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 buf[READ_BUF_SIZE]; data/catimg-2.7.0/src/sh_utils.c:72: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(data+size-count, buf, count); data/catimg-2.7.0/src/stb_image.h:559:18: [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. typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; data/catimg-2.7.0/src/stb_image.h:1078:10: [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(temp, row0, bytes_copy); data/catimg-2.7.0/src/stb_image.h:1079:10: [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(row0, row1, bytes_copy); data/catimg-2.7.0/src/stb_image.h:1080:10: [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(row1, temp, bytes_copy); data/catimg-2.7.0/src/stb_image.h:1168: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). f = fopen(filename, mode); data/catimg-2.7.0/src/stb_image.h:1468:10: [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(buffer, s->img_buffer, blen); data/catimg-2.7.0/src/stb_image.h:1478:7: [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(buffer, s->img_buffer, n); data/catimg-2.7.0/src/stb_image.h:2920:32: [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 const unsigned char tag[5] = {'J','F','I','F','\0'}; data/catimg-2.7.0/src/stb_image.h:2930:32: [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 const unsigned char tag[6] = {'A','d','o','b','e','\0'}; data/catimg-2.7.0/src/stb_image.h:3035:29: [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 const unsigned char rgb[3] = { 'R', 'G', 'B' }; data/catimg-2.7.0/src/stb_image.h:4107:4: [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(a->zout, a->zbuffer, len); data/catimg-2.7.0/src/stb_image.h:4431:40: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. case STBI__F_none: memcpy(cur, raw, nk); break; data/catimg-2.7.0/src/stb_image.h:4587:16: [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(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, data/catimg-2.7.0/src/stb_image.h:5609:13: [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 raw_data[4] = {0}; data/catimg-2.7.0/src/stb_image.h:6506:16: [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( &g->out[pi * 4], &two_back[pi * 4], 4 ); data/catimg-2.7.0/src/stb_image.h:6513:16: [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( &g->out[pi * 4], &g->background[pi * 4], 4 ); data/catimg-2.7.0/src/stb_image.h:6524:7: [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( g->background, g->out, 4 * g->w * g->h ); data/catimg-2.7.0/src/stb_image.h:6581:22: [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( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); data/catimg-2.7.0/src/stb_image.h:6668: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( out + ((layers - 1) * stride), u, stride ); data/catimg-2.7.0/src/stb_image.h:6803: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 buffer[STBI__HDR_BUFLEN]; data/catimg-2.7.0/src/stb_image.h:6931: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 buffer[STBI__HDR_BUFLEN]; data/catimg-2.7.0/src/catimg.c:181:21: [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(img.delays[frame - 1] * 10000); data/catimg-2.7.0/src/catimg.c:183:21: [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(img.delays[img.frames - 1] * 10000); data/catimg-2.7.0/src/sh_utils.c:8:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). #define read _read data/catimg-2.7.0/src/sh_utils.c:62:20: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while((count = read(fd, buf, READ_BUF_SIZE)) > 0) { data/catimg-2.7.0/src/stb_image.h:348:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read data/catimg-2.7.0/src/stb_image.h:1407:19: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); data/catimg-2.7.0/src/stb_image.h:1434:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (s->io.read) { data/catimg-2.7.0/src/stb_image.h:1450:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (s->io.read) { data/catimg-2.7.0/src/stb_image.h:1463:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (s->io.read) { data/catimg-2.7.0/src/stb_image.h:1470:25: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); ANALYSIS SUMMARY: Hits = 48 Lines analyzed = 9238 in approximately 0.26 seconds (35333 lines/second) Physical Source Lines of Code (SLOC) = 6575 Hits@level = [0] 19 [1] 10 [2] 25 [3] 5 [4] 8 [5] 0 Hits@level+ = [0+] 67 [1+] 48 [2+] 38 [3+] 13 [4+] 8 [5+] 0 Hits/KSLOC@level+ = [0+] 10.1901 [1+] 7.30038 [2+] 5.77947 [3+] 1.97719 [4+] 1.21673 [5+] 0 Dot directories skipped = 2 (--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.