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/sord-0.16.6/sord/sord.h Examining data/sord-0.16.6/sord/sordmm.hpp Examining data/sord-0.16.6/src/sord.c Examining data/sord-0.16.6/src/sord_internal.h Examining data/sord-0.16.6/src/sord_test.c Examining data/sord-0.16.6/src/sord_validate.c Examining data/sord-0.16.6/src/sordi.c Examining data/sord-0.16.6/src/sordmm_test.cpp Examining data/sord-0.16.6/src/syntax.c Examining data/sord-0.16.6/src/zix/btree.c Examining data/sord-0.16.6/src/zix/btree.h Examining data/sord-0.16.6/src/zix/common.h Examining data/sord-0.16.6/src/zix/digest.c Examining data/sord-0.16.6/src/zix/digest.h Examining data/sord-0.16.6/src/zix/hash.c Examining data/sord-0.16.6/src/zix/hash.h FINAL RESULTS: data/sord-0.16.6/src/sord.c:34:60: [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. # define SORD_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) data/sord-0.16.6/src/sord.c:39:31: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define SORD_LOG(prefix, ...) fprintf(stderr, "[Sord::" prefix "] " __VA_ARGS__) data/sord-0.16.6/src/sord.c:190:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, fmt, args); data/sord-0.16.6/src/sord_test.c:26:60: [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. # define SORD_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) data/sord-0.16.6/src/sord_test.c:63:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, fmt, args); data/sord-0.16.6/src/sord_test.c:373:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, error->fmt, *error->args); data/sord-0.16.6/src/sord_test.c:381:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, error->fmt, *error->args); data/sord-0.16.6/src/sord_validate.c:37:60: [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. # define SORD_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) data/sord-0.16.6/src/sord_validate.c:141:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, fmt, args); data/sord-0.16.6/src/sordi.c:29:32: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define SORDI_ERROR(msg) fprintf(stderr, "sordi: " msg); data/sord-0.16.6/src/sordi.c:30:32: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define SORDI_ERRORF(fmt, ...) fprintf(stderr, "sordi: " fmt, __VA_ARGS__); data/sord-0.16.6/src/zix/common.h:56:55: [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. #define ZIX_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) data/sord-0.16.6/src/sord_validate.c:130:19: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. return (uint8_t*)realpath((const char*)path, NULL); data/sord-0.16.6/sord/sordmm.hpp:585:19: [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* const fd = fopen(reinterpret_cast<const char*>(path), "w"); data/sord-0.16.6/src/sord.c:913: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(dup, str, len + 1); data/sord-0.16.6/src/sord.c:1163: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(buf, uri_prefix.buf, uri_prefix.len); data/sord-0.16.6/src/sord.c:1164: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(buf + uri_prefix.len, uri_suffix.buf, uri_suffix.len); data/sord-0.16.6/src/sord.c:1224: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(quad, tup, sizeof(SordQuad)); data/sord-0.16.6/src/sord_internal.h:39: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 lang[16]; ///< Optional language tag data/sord-0.16.6/src/sord_validate.c:192: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(regx, pat, len); data/sord-0.16.6/src/sord_validate.c:574:22: [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). const unsigned c = atoi((const char*)sord_node_get_string(card)); data/sord-0.16.6/src/sord_validate.c:587:22: [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). const unsigned m = atoi((const char*)sord_node_get_string(minCard)); data/sord-0.16.6/src/sord_validate.c:600:22: [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). const unsigned m = atoi((const char*)sord_node_get_string(maxCard)); data/sord-0.16.6/src/sordi.c:140:28: [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). if (!input || !(in_fd = fopen((const char*)input, "rb"))) { data/sord-0.16.6/src/zix/btree.c:219: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(rhs->vals, data/sord-0.16.6/src/zix/btree.c:225: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(rhs->children, data/sord-0.16.6/src/zix/btree.c:444: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(lhs->vals + lhs->n_vals, rhs->vals, rhs->n_vals * sizeof(void*)); data/sord-0.16.6/src/zix/btree.c:446: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(lhs->children + lhs->n_vals, data/sord-0.16.6/src/zix/btree.c:760: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(j, i, sizeof(ZixBTreeIter) + s); data/sord-0.16.6/src/zix/hash.c:177: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(elem + 1, value, hash->value_size); data/sord-0.16.6/src/sord.c:1088:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(key.meta.lit.lang, lang, sizeof(key.meta.lit.lang) - 1); data/sord-0.16.6/src/sord_test.c:546: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). } else if (n_bytes != strlen("hello")) { data/sord-0.16.6/src/sord_test.c:551:17: [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 (n_bytes != strlen("hello") || n_chars != strlen("hello")) { data/sord-0.16.6/src/sord_test.c:551:47: [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 (n_bytes != strlen("hello") || n_chars != strlen("hello")) { data/sord-0.16.6/src/sord_validate.c:190:22: [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). const size_t len = strlen((const char*)pat); data/sord-0.16.6/src/sord_validate.c:206:44: [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). const bool ret = pcre_exec(re, NULL, str, strlen(str), 0, 0, NULL, 0) >= 0; data/sord-0.16.6/src/syntax.c:135: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). size_t lang_len = lang_str ? strlen(lang_str) : 0; data/sord-0.16.6/src/zix/btree.c:268:47: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. bool* const equal) data/sord-0.16.6/src/zix/btree.c:291:11: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. assert(!*equal || t->cmp(n->vals[first], e, t->cmp_data) == 0); data/sord-0.16.6/src/zix/btree.c:332:46: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. i = zix_btree_node_find(t, n, e, &equal); data/sord-0.16.6/src/zix/btree.c:333:7: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (equal) { data/sord-0.16.6/src/zix/btree.c:532:56: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. const unsigned i = zix_btree_node_find(t, n, e, &equal); data/sord-0.16.6/src/zix/btree.c:535:8: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (equal) { data/sord-0.16.6/src/zix/btree.c:557:14: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. } else if (equal) { data/sord-0.16.6/src/zix/btree.c:637:56: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. const unsigned i = zix_btree_node_find(t, n, e, &equal); data/sord-0.16.6/src/zix/btree.c:641:7: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (equal) { data/sord-0.16.6/src/zix/btree.c:678:56: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. const unsigned i = zix_btree_node_find(t, n, e, &equal); data/sord-0.16.6/src/zix/btree.c:682:7: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if (equal) { ANALYSIS SUMMARY: Hits = 48 Lines analyzed = 6412 in approximately 0.18 seconds (35232 lines/second) Physical Source Lines of Code (SLOC) = 4659 Hits@level = [0] 74 [1] 18 [2] 17 [3] 1 [4] 12 [5] 0 Hits@level+ = [0+] 122 [1+] 48 [2+] 30 [3+] 13 [4+] 12 [5+] 0 Hits/KSLOC@level+ = [0+] 26.1859 [1+] 10.3026 [2+] 6.43915 [3+] 2.7903 [4+] 2.57566 [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.