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/digup-0.6.57/src/crc32.c Examining data/digup-0.6.57/src/crc32.h Examining data/digup-0.6.57/src/digest.c Examining data/digup-0.6.57/src/digest.h Examining data/digup-0.6.57/src/digup.c Examining data/digup-0.6.57/src/md5.c Examining data/digup-0.6.57/src/md5.h Examining data/digup-0.6.57/src/rbtree.c Examining data/digup-0.6.57/src/rbtree.h Examining data/digup-0.6.57/src/sha1.c Examining data/digup-0.6.57/src/sha1.h Examining data/digup-0.6.57/src/sha256.c Examining data/digup-0.6.57/src/sha256.h Examining data/digup-0.6.57/src/sha512.c Examining data/digup-0.6.57/src/sha512.h Examining data/digup-0.6.57/src/test_digest.c Examining data/digup-0.6.57/src/test_digup.c Examining data/digup-0.6.57/src/test_rbtree.c FINAL RESULTS: data/digup-0.6.57/src/digup.c:318:11: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. nchars = readlink(filename, buffer, size); data/digup-0.6.57/src/digup.c:194:11: [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. len = vsnprintf(NULL, 0, fmt, ap) + 1; data/digup-0.6.57/src/digup.c:201:11: [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. len = vsnprintf(out, len, fmt, ap); data/digup-0.6.57/src/digup.c:349:11: [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. len = vsnprintf(NULL, 0, fmt, ap) + 1; data/digup-0.6.57/src/digup.c:367:11: [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. len = vsnprintf(out, len, fmt, ap); data/digup-0.6.57/src/digup.c:1114:9: [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. if (access("md5sum.txt", F_OK) == 0) data/digup-0.6.57/src/digup.c:1120:9: [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. if (access("sha1sum.txt", F_OK) == 0) data/digup-0.6.57/src/digup.c:1133:9: [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. if (access("sha128sum.txt", F_OK) == 0) data/digup-0.6.57/src/digup.c:1146:9: [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. if (access("sha256sum.txt", F_OK) == 0) data/digup-0.6.57/src/digup.c:1159:9: [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. if (access("sha512sum.txt", F_OK) == 0) data/digup-0.6.57/src/digup.c:1462:7: [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. if (access((char*)nodecopy->value, F_OK) == 0) data/digup-0.6.57/src/digup.c:2483:10: [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. int c = getopt_long(argc, argv, "bcd:f:hlmqr:t:uvVw", data/digup-0.6.57/src/test_rbtree.c:58:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(4545); data/digup-0.6.57/src/test_rbtree.c:66:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(4545); data/digup-0.6.57/src/test_rbtree.c:83:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(4545); data/digup-0.6.57/src/test_rbtree.c:129:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(4545); data/digup-0.6.57/src/test_rbtree.c:137:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(4545); data/digup-0.6.57/src/test_rbtree.c:154:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(4545); data/digup-0.6.57/src/digest.c:329: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((char*)newres+1, (char*)res+1, res->size); data/digup-0.6.57/src/digest.c:338: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. static const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', data/digup-0.6.57/src/digest.c:360: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. static const char hexval[256] = { data/digup-0.6.57/src/digup.c:502: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 buffer[1024*1024]; data/digup-0.6.57/src/digup.c:513:14: [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). int fd = open(filepath, openflags | O_NOATIME); data/digup-0.6.57/src/digup.c:518:7: [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(filepath, openflags); data/digup-0.6.57/src/digup.c:521:14: [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). int fd = open(filepath, openflags); data/digup-0.6.57/src/digup.c:826:3: [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(fileinfo, tempinfo, sizeof(struct FileInfo)); data/digup-0.6.57/src/digup.c:878:3: [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(fileinfo, tempinfo, sizeof(struct FileInfo)); data/digup-0.6.57/src/digup.c:940: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 input[256], *r; data/digup-0.6.57/src/digup.c:1001: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(fileinfo, tempinfo, sizeof(struct FileInfo)); data/digup-0.6.57/src/digup.c:1205:15: [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). sumfile = fopen(gopt_digestfile, "rb"); data/digup-0.6.57/src/digup.c:2284: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 *sumfile = fopen(gopt_digestfile, "wb"); data/digup-0.6.57/src/digup.c:2287: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 digeststr[128]; data/digup-0.6.57/src/digup.c:2301: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 datenow[64]; data/digup-0.6.57/src/digup.c:2682: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 input[256]; data/digup-0.6.57/src/md5.c:62:23: [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 fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; data/digup-0.6.57/src/md5.c:85: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 (cp, &v, sizeof v); data/digup-0.6.57/src/md5.c:120: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 (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); data/digup-0.6.57/src/md5.c:158: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 (&((char *) ctx->buffer)[left_over], buffer, add); data/digup-0.6.57/src/md5.c:167:6: [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 (ctx->buffer, data/digup-0.6.57/src/md5.c:185: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. md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); data/digup-0.6.57/src/md5.c:203: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 (&((char *) ctx->buffer)[left_over], buffer, len); data/digup-0.6.57/src/md5.c:209:6: [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 (ctx->buffer, &ctx->buffer[16], left_over); data/digup-0.6.57/src/sha1.c:61:23: [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 fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; data/digup-0.6.57/src/sha1.c:86: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 (cp, &v, sizeof v); data/digup-0.6.57/src/sha1.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 (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); data/digup-0.6.57/src/sha1.c:159: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 (&((char *) ctx->buffer)[left_over], buffer, add); data/digup-0.6.57/src/sha1.c:168:6: [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 (ctx->buffer, data/digup-0.6.57/src/sha1.c:186:23: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); data/digup-0.6.57/src/sha1.c:204: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 (&((char *) ctx->buffer)[left_over], buffer, len); data/digup-0.6.57/src/sha1.c:210:6: [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 (ctx->buffer, &ctx->buffer[16], left_over); data/digup-0.6.57/src/sha256.c:62:23: [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 fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; data/digup-0.6.57/src/sha256.c:108: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 (cp, &v, sizeof v); data/digup-0.6.57/src/sha256.c:159: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 (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); data/digup-0.6.57/src/sha256.c:223: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 (&((char *) ctx->buffer)[left_over], buffer, add); data/digup-0.6.57/src/sha256.c:232:6: [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 (ctx->buffer, data/digup-0.6.57/src/sha256.c:250: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. sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); data/digup-0.6.57/src/sha256.c:268: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 (&((char *) ctx->buffer)[left_over], buffer, len); data/digup-0.6.57/src/sha256.c:274:6: [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 (ctx->buffer, &ctx->buffer[16], left_over); data/digup-0.6.57/src/sha512.c:85:23: [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 fillbuf[128] = { 0x80, 0 /* , 0, 0, ... */ }; data/digup-0.6.57/src/sha512.c:131: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 (cp, &v, sizeof v); data/digup-0.6.57/src/sha512.c:183: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 (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 8 - bytes); data/digup-0.6.57/src/sha512.c:247: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 (&((char *) ctx->buffer)[left_over], buffer, add); data/digup-0.6.57/src/sha512.c:256:6: [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 (ctx->buffer, data/digup-0.6.57/src/sha512.c:274: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. sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128, ctx); data/digup-0.6.57/src/sha512.c:292: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 (&((char *) ctx->buffer)[left_over], buffer, len); data/digup-0.6.57/src/sha512.c:298:6: [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 (ctx->buffer, &ctx->buffer[16], left_over); data/digup-0.6.57/src/test_digest.c:93:11: [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 str2[65536]; data/digup-0.6.57/src/test_rbtree.c:49: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 str[512]; data/digup-0.6.57/src/digest.c:382: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). if (len < 0) len = strlen(str); data/digup-0.6.57/src/digest.h:69:29: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). struct digest_result* (*read)(struct digest_ctx *ctx); data/digup-0.6.57/src/digup.c:179:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(out, str, len); data/digup-0.6.57/src/digup.c:268:17: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((c = fgetc(stream)) != EOF) data/digup-0.6.57/src/digup.c:542:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while( (rb = read(fd, &buffer, sizeof(buffer))) > 0 ) data/digup-0.6.57/src/digup.c:2696:10: [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(input) > 0 && input[strlen(input)-1] == '\n') data/digup-0.6.57/src/digup.c:2696: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 (strlen(input) > 0 && input[strlen(input)-1] == '\n') data/digup-0.6.57/src/digup.c:2697: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). input[strlen(input)-1] = 0; data/digup-0.6.57/src/digup.c:2701:39: [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 (strncmp(input, cmdlist[i].name, strlen(input)) == 0) data/digup-0.6.57/src/test_digest.c:74:14: [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). check(str1, strlen(str1), &digest_md5, data/digup-0.6.57/src/test_digest.c:77:14: [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). check(str1, strlen(str1), &digest_sha1, data/digup-0.6.57/src/test_digest.c:80:14: [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). check(str1, strlen(str1), &digest_sha256, data/digup-0.6.57/src/test_digest.c:83:14: [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). check(str1, strlen(str1), &digest_sha512, data/digup-0.6.57/src/test_digest.c:87:14: [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). check(str1, strlen(str1), &digest_crc32, ANALYSIS SUMMARY: Hits = 82 Lines analyzed = 6679 in approximately 0.22 seconds (30551 lines/second) Physical Source Lines of Code (SLOC) = 4515 Hits@level = [0] 185 [1] 14 [2] 50 [3] 7 [4] 10 [5] 1 Hits@level+ = [0+] 267 [1+] 82 [2+] 68 [3+] 18 [4+] 11 [5+] 1 Hits/KSLOC@level+ = [0+] 59.1362 [1+] 18.1617 [2+] 15.0609 [3+] 3.98671 [4+] 2.43632 [5+] 0.221484 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.