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/recoverjpeg-2.6.3/src/recoverjpeg.c Examining data/recoverjpeg-2.6.3/src/recovermov.cpp Examining data/recoverjpeg-2.6.3/src/utils.c Examining data/recoverjpeg-2.6.3/src/utils.h FINAL RESULTS: data/recoverjpeg-2.6.3/src/recoverjpeg.c:193:5: [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(dir_buffer, "/", sizeof dir_buffer - 1); data/recoverjpeg-2.6.3/src/recoverjpeg.c:186:5: [4] (format) snprintf: 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. snprintf(dir_buffer, sizeof dir_buffer, dir_format, index / 100); data/recoverjpeg-2.6.3/src/recoverjpeg.c:199:3: [4] (format) snprintf: 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. snprintf(file_buffer, sizeof file_buffer, file_format, index); data/recoverjpeg-2.6.3/src/recoverjpeg.c:226:15: [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, (char * const *) argv, "b:d:f:hi:m:o:qr:s:S:vV")) != -1) { data/recoverjpeg-2.6.3/src/recovermov.cpp:113:15: [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, "b:f:hi:m:o:qr:vV")) != -1) { data/recoverjpeg-2.6.3/src/recoverjpeg.c:182: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 dir_buffer[200]; data/recoverjpeg-2.6.3/src/recoverjpeg.c:183: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 file_buffer[100]; data/recoverjpeg-2.6.3/src/recoverjpeg.c:238:21: [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). begin_index = atoi(optarg); data/recoverjpeg-2.6.3/src/recoverjpeg.c:275:8: [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). fd = open(argv[0], O_RDONLY); data/recoverjpeg-2.6.3/src/recoverjpeg.c:343:15: [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). fdout = open(buffer, O_WRONLY | O_CREAT, 0666); data/recoverjpeg-2.6.3/src/recovermov.cpp:122:19: [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). mov_index = atoi(optarg); data/recoverjpeg-2.6.3/src/utils.c:54:10: [2] (integer) atol: 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). return atol(arg) * multiplier; data/recoverjpeg-2.6.3/src/utils.c:87: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 buffer[512]; data/recoverjpeg-2.6.3/src/recoverjpeg.c:200:3: [1] (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. strncat(dir_buffer, file_buffer, data/recoverjpeg-2.6.3/src/recoverjpeg.c:201:24: [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). sizeof dir_buffer - strlen(dir_buffer) - 1); data/recoverjpeg-2.6.3/src/recoverjpeg.c:324:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). n = read(fd, start, read_size); data/recoverjpeg-2.6.3/src/utils.c:32: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). switch (arg[strlen(arg) - 1]) { data/recoverjpeg-2.6.3/src/utils.c:51:9: [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). arg[strlen(arg) - 1] = '\0'; ANALYSIS SUMMARY: Hits = 18 Lines analyzed = 703 in approximately 0.03 seconds (23241 lines/second) Physical Source Lines of Code (SLOC) = 532 Hits@level = [0] 38 [1] 5 [2] 8 [3] 2 [4] 2 [5] 1 Hits@level+ = [0+] 56 [1+] 18 [2+] 13 [3+] 5 [4+] 3 [5+] 1 Hits/KSLOC@level+ = [0+] 105.263 [1+] 33.8346 [2+] 24.4361 [3+] 9.3985 [4+] 5.6391 [5+] 1.8797 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.