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/libgringotts-1.2.1/src/libgrg_structs.c Examining data/libgringotts-1.2.1/src/libgrg_structs.h Examining data/libgringotts-1.2.1/src/libgrg_utils.c Examining data/libgringotts-1.2.1/src/libgrg_utils.h Examining data/libgringotts-1.2.1/src/libgringotts.h Examining data/libgringotts-1.2.1/src/libgrg_crypt.h Examining data/libgringotts-1.2.1/src/libgrg_tmp.c Examining data/libgringotts-1.2.1/src/libgrg_crypt.c Examining data/libgringotts-1.2.1/src/test.c FINAL RESULTS: data/libgringotts-1.2.1/src/libgrg_structs.h:59:9: [4] (crypto) crypt: The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment (CWE-327). Use a different algorithm, such as SHA-256, with a larger, non-repeating salt. MCRYPT crypt; data/libgringotts-1.2.1/src/libgrg_tmp.c:106:31: [4] (crypto) crypt: The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment (CWE-327). Use a different algorithm, such as SHA-256, with a larger, non-repeating salt. if (mcrypt_generic_init (tf->crypt, tf->key, tf->dKey, tf->IV) < 0) data/libgringotts-1.2.1/src/libgrg_tmp.c:115:26: [4] (crypto) crypt: The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment (CWE-327). Use a different algorithm, such as SHA-256, with a larger, non-repeating salt. if (mcrypt_generic (tf->crypt, tocrypt, dim + HEADER_LEN)) data/libgringotts-1.2.1/src/libgrg_tmp.c:117:30: [4] (crypto) crypt: The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment (CWE-327). Use a different algorithm, such as SHA-256, with a larger, non-repeating salt. mcrypt_generic_deinit (tf->crypt); data/libgringotts-1.2.1/src/libgrg_tmp.c:125:29: [4] (crypto) crypt: The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment (CWE-327). Use a different algorithm, such as SHA-256, with a larger, non-repeating salt. mcrypt_generic_deinit (tf->crypt); data/libgringotts-1.2.1/src/libgrg_tmp.c:147:31: [4] (crypto) crypt: The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment (CWE-327). Use a different algorithm, such as SHA-256, with a larger, non-repeating salt. if (mcrypt_generic_init (tf->crypt, tf->key, tf->dKey, tf->IV) < 0) data/libgringotts-1.2.1/src/libgrg_tmp.c:160:28: [4] (crypto) crypt: The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment (CWE-327). Use a different algorithm, such as SHA-256, with a larger, non-repeating salt. if (mdecrypt_generic (tf->crypt, enc_data, dim + HEADER_LEN)) data/libgringotts-1.2.1/src/libgrg_tmp.c:194:27: [4] (crypto) crypt: The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment (CWE-327). Use a different algorithm, such as SHA-256, with a larger, non-repeating salt. mcrypt_module_close (tf->crypt); data/libgringotts-1.2.1/src/libgrg_structs.c:55:33: [3] (random) random: 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. #warning compiling without /dev/random data/libgringotts-1.2.1/src/libgrg_structs.c:56:2: [3] (random) srandom: 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. srandom ((unsigned int) time (NULL)); data/libgringotts-1.2.1/src/libgrg_utils.c:235:9: [3] (random) random: 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. val = random (); data/libgringotts-1.2.1/src/libgrg_utils.c:240:21: [3] (random) random: 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. toOverwrite[i] = (random () / 256) % 256; data/libgringotts-1.2.1/src/libgrg_utils.c:286:9: [3] (random) random: 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. rnd = (random () / 256) % 256; data/libgringotts-1.2.1/src/libgrg_crypt.c:560: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 *) *mem), gctx->header, HEADER_LEN); data/libgringotts-1.2.1/src/libgrg_crypt.c:561: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 *) *mem)[HEADER_LEN] = LIBGRG_FILE_VERSION + '0'; data/libgringotts-1.2.1/src/libgrg_crypt.c:562: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 *) *mem) + HEADER_LEN + LIBGRG_FILE_VERSION_LEN, CRC2, data/libgringotts-1.2.1/src/libgrg_crypt.c:566: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 *) *mem) + LIBGRG_ALGO_POS, toCRC2, compDim); data/libgringotts-1.2.1/src/libgrg_crypt.c:608: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 (path, O_RDONLY); data/libgringotts-1.2.1/src/libgrg_crypt.c:641: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. update_gctx_from_mem (gctx, ((char *) mem)[LIBGRG_ALGO_POS]); data/libgringotts-1.2.1/src/libgrg_crypt.c:656: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 (path, O_RDONLY); data/libgringotts-1.2.1/src/libgrg_crypt.c:690: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. update_gctx_from_mem (gctx, ((char *) mem)[LIBGRG_ALGO_POS]); data/libgringotts-1.2.1/src/libgrg_crypt.c:709: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 (path, O_RDONLY); data/libgringotts-1.2.1/src/libgrg_crypt.c:761: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 (path, O_WRONLY | O_CREAT | O_TRUNC, data/libgringotts-1.2.1/src/libgrg_crypt.c:798: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. update_gctx_from_mem (gctx, ((char *) mem)[LIBGRG_ALGO_POS]); data/libgringotts-1.2.1/src/libgrg_crypt.c:817: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. update_gctx_from_mem (gctx, ((char *) mem)[LIBGRG_ALGO_POS]); data/libgringotts-1.2.1/src/libgrg_structs.c:45: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). gctx->rnd = open ("/dev/random", O_RDONLY); data/libgringotts-1.2.1/src/libgrg_structs.c:47: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). gctx->rnd = open ("/dev/urandom", O_RDONLY); data/libgringotts-1.2.1/src/libgrg_structs.c:93: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 (ret->header, header, HEADER_LEN); data/libgringotts-1.2.1/src/libgrg_structs.c:236: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 (clone, src, sizeof (struct _grg_key)); data/libgringotts-1.2.1/src/libgrg_structs.h:34: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 header[3]; data/libgringotts-1.2.1/src/libgrg_structs.h:44: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 key_192_ripe[24]; data/libgringotts-1.2.1/src/libgrg_structs.h:45: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 key_256_ripe[32]; data/libgringotts-1.2.1/src/libgrg_structs.h:46: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 key_192_sha[24]; data/libgringotts-1.2.1/src/libgrg_structs.h:47: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 key_256_sha[32]; data/libgringotts-1.2.1/src/libgrg_tmp.c:50: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 (tmpname + 5, gctx->header, HEADER_LEN); data/libgringotts-1.2.1/src/libgrg_tmp.c:51:14: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). tf->tmpfd = mkstemp (tmpname); data/libgringotts-1.2.1/src/libgrg_tmp.c:53: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 (tmpname, "/tmp/___-XXXXXX", 15); data/libgringotts-1.2.1/src/libgrg_utils.c:70: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 (ret, src, len); data/libgringotts-1.2.1/src/libgrg_utils.c:90: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 *ret, *tmp, *strings[count]; data/libgringotts-1.2.1/src/libgrg_utils.c:115: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 (tmp, strings[i], dim[i]); data/libgringotts-1.2.1/src/libgrg_utils.c:236: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 (toOverwrite + i, &val, step); data/libgringotts-1.2.1/src/libgrg_utils.c:442: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). pdf = open (pwd_path, O_RDONLY); data/libgringotts-1.2.1/src/libgrg_utils.c:468: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. static const char index_64[128] = { data/libgringotts-1.2.1/src/libgrg_utils.c:603: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 (path, O_RDWR); data/libgringotts-1.2.1/src/test.c:189: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 (rs1, rs2, TEST_DIM); data/libgringotts-1.2.1/src/test.c:221:11: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int fd = mkstemp (name); data/libgringotts-1.2.1/src/test.c:230: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 (name, O_RDONLY); data/libgringotts-1.2.1/src/test.c:287:12: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int fd1 = mkstemp (name1); data/libgringotts-1.2.1/src/test.c:290:12: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int fd2 = mkstemp (name2); data/libgringotts-1.2.1/src/test.c:293:12: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int fd3 = mkstemp (name3); data/libgringotts-1.2.1/src/test.c:391:11: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int fd = mkstemp (name); data/libgringotts-1.2.1/src/test.c:405: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 (name, O_RDONLY); data/libgringotts-1.2.1/src/test.c:430:11: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int fd = mkstemp (name); data/libgringotts-1.2.1/src/test.c:439: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 (name, O_RDONLY); data/libgringotts-1.2.1/src/test.c:461:7: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). fd = mkstemp (name); data/libgringotts-1.2.1/src/test.c:495:7: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). fd = mkstemp (name); data/libgringotts-1.2.1/src/libgrg_crypt.c:85:52: [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). get_CRC32 (const unsigned char *string, const long strlen) data/libgringotts-1.2.1/src/libgrg_crypt.c:95:21: [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). mhash (td, string, strlen); data/libgringotts-1.2.1/src/libgrg_crypt.c:180:33: [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). rem = (memDim >= 0) ? memDim : strlen (mem); data/libgringotts-1.2.1/src/libgrg_crypt.c:403:27: [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). uncDim = (origDim < 0) ? strlen (origData) : origDim; data/libgringotts-1.2.1/src/libgrg_structs.c:84:18: [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 (!header || (strlen (header) != HEADER_LEN)) data/libgringotts-1.2.1/src/libgrg_structs.c:207:18: [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). real_pwd_len = strlen (pwd); data/libgringotts-1.2.1/src/libgrg_tmp.c:109:25: [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). dim = (data_len < 0) ? strlen (data) : data_len; data/libgringotts-1.2.1/src/libgrg_tmp.c:152:2: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read (tf->tmpfd, &dim, sizeof (long)); data/libgringotts-1.2.1/src/libgrg_tmp.c:158:2: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read (tf->tmpfd, enc_data, dim + HEADER_LEN); data/libgringotts-1.2.1/src/libgrg_utils.c:225:11: [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). csize = strlen (toOverwrite); data/libgringotts-1.2.1/src/libgrg_utils.c:228:2: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read (gctx->rnd, toOverwrite, csize); data/libgringotts-1.2.1/src/libgrg_utils.c:284:2: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read (gctx->rnd, &rnd, 1); data/libgringotts-1.2.1/src/libgrg_utils.c:307:54: [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). grg_rnd_seq_direct (gctx, pntr, (dim >= 0) ? dim : strlen (pntr)); data/libgringotts-1.2.1/src/libgrg_utils.c:490:35: [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). origlen = (inlen >= 0) ? inlen : strlen (in); data/libgringotts-1.2.1/src/libgrg_utils.c:536:36: [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). tmpinlen = (inlen >= 0) ? inlen : strlen (in); ANALYSIS SUMMARY: Hits = 71 Lines analyzed = 2930 in approximately 0.22 seconds (13038 lines/second) Physical Source Lines of Code (SLOC) = 2010 Hits@level = [0] 23 [1] 15 [2] 43 [3] 5 [4] 8 [5] 0 Hits@level+ = [0+] 94 [1+] 71 [2+] 56 [3+] 13 [4+] 8 [5+] 0 Hits/KSLOC@level+ = [0+] 46.7662 [1+] 35.3234 [2+] 27.8607 [3+] 6.46766 [4+] 3.9801 [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.