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/grim-1.3.1+ds/box.c Examining data/grim-1.3.1+ds/buffer.c Examining data/grim-1.3.1+ds/cairo_ppm.c Examining data/grim-1.3.1+ds/include/box.h Examining data/grim-1.3.1+ds/include/buffer.h Examining data/grim-1.3.1+ds/include/cairo_ppm.h Examining data/grim-1.3.1+ds/include/grim.h Examining data/grim-1.3.1+ds/include/output-layout.h Examining data/grim-1.3.1+ds/include/render.h Examining data/grim-1.3.1+ds/main.c Examining data/grim-1.3.1+ds/output-layout.c Examining data/grim-1.3.1+ds/render.c FINAL RESULTS: data/grim-1.3.1+ds/main.c:224:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(tmpstr, "%%Y%%m%%d_%%Hh%%Mm%%Ss_grim.%s", ext); data/grim-1.3.1+ds/main.c:234:17: [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. return path && access(path, R_OK) != -1; data/grim-1.3.1+ds/main.c:255:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(output_path, "%s/%s", output_dir, filename); data/grim-1.3.1+ds/main.c:378: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(output_filepath, output_filename); data/grim-1.3.1+ds/main.c:244:16: [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 *path = getenv(output_dirs[i]); data/grim-1.3.1+ds/main.c:279:16: [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 ((opt = getopt(argc, argv, "hs:g:t:q:o:c")) != -1) { data/grim-1.3.1+ds/cairo_ppm.c:18:2: [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 header[256]; data/grim-1.3.1+ds/cairo_ppm.c:31: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(buffer, header, header_len); data/grim-1.3.1+ds/cairo_ppm.c:84:12: [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). outfile = open(filename, data/grim-1.3.1+ds/main.c:223:2: [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 tmpstr[32]; data/grim-1.3.1+ds/main.c:362:2: [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 output_filepath[PATH_MAX]; data/grim-1.3.1+ds/main.c:364:2: [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 tmp[64]; data/grim-1.3.1+ds/main.c:436: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(geometry, &output->logical_geometry, data/grim-1.3.1+ds/buffer.c:28:19: [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). randname(name + strlen(name) - 6); data/grim-1.3.1+ds/main.c:374:7: [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(output_filename) >= PATH_MAX) { data/grim-1.3.1+ds/main.c:528:45: [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 (status == CAIRO_STATUS_WRITE_ERROR && strlen(output_filepath) > NAME_MAX) { ANALYSIS SUMMARY: Hits = 16 Lines analyzed = 1125 in approximately 0.07 seconds (17159 lines/second) Physical Source Lines of Code (SLOC) = 942 Hits@level = [0] 25 [1] 3 [2] 7 [3] 2 [4] 4 [5] 0 Hits@level+ = [0+] 41 [1+] 16 [2+] 13 [3+] 6 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 43.5244 [1+] 16.9851 [2+] 13.8004 [3+] 6.36943 [4+] 4.24628 [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.