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/libkibi-0.1.1/kibi/kibi.h Examining data/libkibi-0.1.1/kibi/kibi.c Examining data/libkibi-0.1.1/test/test.c FINAL RESULTS: data/libkibi-0.1.1/kibi/kibi.c:31:28: [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 debug(format, ...) printf("libkibi: DEBUG: " format, __VA_ARGS__) data/libkibi-0.1.1/kibi/kibi.c:36:28: [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 malloc_error(size) fprintf(stderr, \ data/libkibi-0.1.1/kibi/kibi.c:422:13: [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(user_config_file, R_OK)) { data/libkibi-0.1.1/kibi/kibi.c:426: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. if(!access(user_config_file, F_OK)) { data/libkibi-0.1.1/kibi/kibi.c:438:13: [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(SYSTEM_CONFIG_FILE, R_OK)) { data/libkibi-0.1.1/kibi/kibi.c:442: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. if(!access(SYSTEM_CONFIG_FILE, F_OK)) { data/libkibi-0.1.1/kibi/kibi.c:313:23: [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. xdg_config_home = getenv("XDG_CONFIG_HOME"); data/libkibi-0.1.1/kibi/kibi.c:323: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. home = getenv("HOME"); data/libkibi-0.1.1/kibi/kibi.c:416:22: [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. byteprefix_env = getenv("BYTEPREFIX"); data/libkibi-0.1.1/kibi/kibi.c:59: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. const char *prefix[PREFIX_COUNT]; data/libkibi-0.1.1/kibi/kibi.c:60: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. const char *size[PREFIX_COUNT]; data/libkibi-0.1.1/kibi/kibi.c:61: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. const char *transfer_rate[PREFIX_COUNT]; data/libkibi-0.1.1/kibi/kibi.c:390: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[MAX_LEN + 1]; data/libkibi-0.1.1/kibi/kibi.c:394:14: [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). stream = fopen(user_config_file, "r"); data/libkibi-0.1.1/kibi/kibi.c:626: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 base2_size[BASE2_SIZE_LENGTH]; data/libkibi-0.1.1/kibi/kibi.c:627: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 base10_size[BASE10_SIZE_LENGTH]; data/libkibi-0.1.1/test/test.c:31: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 *format[PREFIX_TYPES]; data/libkibi-0.1.1/test/test.c:37: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 *format[PREFIX_TYPES]; data/libkibi-0.1.1/test/test.c:55: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 *format[PREFIX_TYPES]; data/libkibi-0.1.1/test/test.c:63: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 *format[PREFIX_TYPES]; data/libkibi-0.1.1/test/test.c:99: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 *prefix[PREFIX_TYPES] = {"base10", "base2", "historic"}; data/libkibi-0.1.1/test/test.c:483: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 fix_formatted_size[DEST_BUFFER_LENGTH]; data/libkibi-0.1.1/test/test.c:556: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 fix_formatted_size[DEST_BUFFER_LENGTH]; data/libkibi-0.1.1/kibi/kibi.c:76:26: [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). length = 3 + 1 + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:93:30: [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). length = 4 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:93:57: [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). length = 4 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:105:30: [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). length = 5 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:105:57: [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). length = 5 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:131:26: [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). length = 4 + 1 + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:151:30: [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). length = 4 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:151:57: [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). length = 4 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:164:34: [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). length = 5 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:164:61: [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). length = 5 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:176:34: [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). length = 4 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:176:61: [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). length = 4 + 1 + strlen(units->prefix[i]) + strlen(suffix) + 1; data/libkibi-0.1.1/kibi/kibi.c:314: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). if(xdg_config_home != NULL && strlen(xdg_config_home) > 0) { data/libkibi-0.1.1/kibi/kibi.c:315: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). length = strlen(xdg_config_home) + 1; data/libkibi-0.1.1/kibi/kibi.c:324: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). length = strlen(home) + 1 + strlen(config_dir) + 1; data/libkibi-0.1.1/kibi/kibi.c:324: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). length = strlen(home) + 1 + strlen(config_dir) + 1; data/libkibi-0.1.1/kibi/kibi.c:344: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). length = strlen(xdg_config_home) + 1 + strlen(config_file) + 1; data/libkibi-0.1.1/kibi/kibi.c:344: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). length = strlen(xdg_config_home) + 1 + strlen(config_file) + 1; data/libkibi-0.1.1/kibi/kibi.c:362:13: [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). for(i = strlen(str) - 1; i >= 0; i--) { data/libkibi-0.1.1/kibi/kibi.c:397: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). if(!strncmp("format=", buffer, strlen("format="))) { data/libkibi-0.1.1/kibi/kibi.c:398:34: [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). format = &buffer[strlen("format=")]; data/libkibi-0.1.1/kibi/kibi.c:517: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). length = strlen(base10_size) + 1 + strlen(base2_size) + 1; data/libkibi-0.1.1/kibi/kibi.c:517: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). length = strlen(base10_size) + 1 + strlen(base2_size) + 1; data/libkibi-0.1.1/test/test.c:372:13: [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. static bool equal(double a, double b) { data/libkibi-0.1.1/test/test.c:388:12: [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(result, testcase->divided_size[format])) { data/libkibi-0.1.1/test/test.c:498: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(strings_equal && (length == (int)strlen(testcase->format[format]))) { data/libkibi-0.1.1/test/test.c:508:20: [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). strlen(testcase->format[format])); data/libkibi-0.1.1/test/test.c:571: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(strings_equal && (length == (int)strlen(testcase->format[format]))) { data/libkibi-0.1.1/test/test.c:581:20: [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). strlen(testcase->format[format])); ANALYSIS SUMMARY: Hits = 52 Lines analyzed = 1686 in approximately 0.08 seconds (20947 lines/second) Physical Source Lines of Code (SLOC) = 1209 Hits@level = [0] 58 [1] 29 [2] 14 [3] 3 [4] 6 [5] 0 Hits@level+ = [0+] 110 [1+] 52 [2+] 23 [3+] 9 [4+] 6 [5+] 0 Hits/KSLOC@level+ = [0+] 90.9843 [1+] 43.0108 [2+] 19.024 [3+] 7.44417 [4+] 4.96278 [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.