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/kafkacat-1.6.0/avro.c Examining data/kafkacat-1.6.0/format.c Examining data/kafkacat-1.6.0/json.c Examining data/kafkacat-1.6.0/kafkacat.c Examining data/kafkacat-1.6.0/kafkacat.h Examining data/kafkacat-1.6.0/mklove/modules/configure.cc Examining data/kafkacat-1.6.0/rdendian.h Examining data/kafkacat-1.6.0/rdport.h Examining data/kafkacat-1.6.0/tools.c Examining data/kafkacat-1.6.0/win32/getdelim.c Examining data/kafkacat-1.6.0/win32/win32_config.h Examining data/kafkacat-1.6.0/win32/wingetopt.c Examining data/kafkacat-1.6.0/win32/wingetopt.h FINAL RESULTS: data/kafkacat-1.6.0/format.c:247:25: [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(errstr, errstr_size, \ data/kafkacat-1.6.0/format.c:323:25: [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. fprintf(fp, "%"PRId64, v); data/kafkacat-1.6.0/format.c:331:25: [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. fprintf(fp, "%"PRIu64, v); data/kafkacat-1.6.0/format.c:393:29: [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. r = fprintf(fp, "%"PRId64, rkmessage->offset); data/kafkacat-1.6.0/format.c:507:29: [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. r = fprintf(fp, "%"PRId32, rkmessage->partition); data/kafkacat-1.6.0/format.c:514:29: [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. r = fprintf(fp, "%"PRId64, data/kafkacat-1.6.0/json.c:230:17: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(host, "%s:%i", data/kafkacat-1.6.0/json.c:360:17: [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(partstr, sizeof(partstr), "%"PRId32, p->partition); data/kafkacat-1.6.0/kafkacat.c:98:9: [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. vsnprintf(buf, sizeof(buf), fmt, ap); data/kafkacat-1.6.0/kafkacat.c:114:9: [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. vsnprintf(buf, sizeof(buf), fmt, ap); data/kafkacat-1.6.0/kafkacat.c:957:33: [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. printf("%s%"PRId32, data/kafkacat-1.6.0/kafkacat.c:963:33: [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. printf("%s%"PRId32, data/kafkacat-1.6.0/kafkacat.h:171:25: [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. fprintf(stderr, "%% " __VA_ARGS__); \ data/kafkacat-1.6.0/win32/wingetopt.c:121:11: [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. (void)vfprintf(stderr,fmt,ap); data/kafkacat-1.6.0/kafkacat.c:1613:21: [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. if (!(val = getenv(env)) || !*val) data/kafkacat-1.6.0/kafkacat.c:1673:23: [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 ((opt = getopt(argc, argv, data/kafkacat-1.6.0/kafkacat.c:2091:9: [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(tv.tv_usec); data/kafkacat-1.6.0/win32/wingetopt.c:349: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. posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); data/kafkacat-1.6.0/win32/wingetopt.c:525:1: [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. getopt(int nargc, char * const *nargv, const char *options) data/kafkacat-1.6.0/win32/wingetopt.c:545:1: [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. getopt_long(int nargc, char * const *nargv, const char *options, data/kafkacat-1.6.0/win32/wingetopt.h:29:12: [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. extern int getopt(int nargc, char * const *nargv, const char *options); data/kafkacat-1.6.0/win32/wingetopt.h:77:12: [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. extern int getopt_long(int nargc, char * const *nargv, const char *options, data/kafkacat-1.6.0/avro.c:48:9: [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 errstr[256]; data/kafkacat-1.6.0/avro.c:50:20: [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 (!(fp = fopen(path, "r"))) data/kafkacat-1.6.0/avro.c:87:9: [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 errstr[512]; data/kafkacat-1.6.0/format.c:44:17: [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(d, str, len); data/kafkacat-1.6.0/format.c:254:17: [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(dst, b, sz); \ data/kafkacat-1.6.0/format.c:381:9: [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 errstr[256]; data/kafkacat-1.6.0/json.c:119:25: [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 errstr[256]; data/kafkacat-1.6.0/json.c:150:25: [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 errstr[256]; data/kafkacat-1.6.0/json.c:347:17: [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 partstr[16]; data/kafkacat-1.6.0/kafkacat.c:95:9: [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 buf[1024]; data/kafkacat-1.6.0/kafkacat.c:111:9: [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 buf[1024]; data/kafkacat-1.6.0/kafkacat.c:226:27: [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). if ((fd = _COMPAT(open)(path, O_RDONLY)) == -1) { data/kafkacat-1.6.0/kafkacat.c:298:9: [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 errstr[512]; data/kafkacat-1.6.0/kafkacat.c:299:9: [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 tmp[2]; data/kafkacat-1.6.0/kafkacat.c:656:9: [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 errstr[512]; data/kafkacat-1.6.0/kafkacat.c:763:9: [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 errstr[512]; data/kafkacat-1.6.0/kafkacat.c:978:9: [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 errstr[512]; data/kafkacat-1.6.0/kafkacat.c:1036:9: [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 features[256]; data/kafkacat-1.6.0/kafkacat.c:1306:17: [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 fatal_errstr[512]; data/kafkacat-1.6.0/kafkacat.c:1496:17: [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 sasl_user[128], sasl_pass[128]; data/kafkacat-1.6.0/kafkacat.c:1522:9: [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 buf[512]; data/kafkacat-1.6.0/kafkacat.c:1525:20: [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 (!(fp = fopen(path, "r"))) { data/kafkacat-1.6.0/kafkacat.c:1537:17: [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 errstr[512]; data/kafkacat-1.6.0/kafkacat.c:1620:9: [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 path[512]; data/kafkacat-1.6.0/kafkacat.c:1663:9: [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 errstr[512]; data/kafkacat-1.6.0/kafkacat.c:1668:9: [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 tmp_fmt[64]; data/kafkacat-1.6.0/kafkacat.c:1704:42: [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). conf.partition = atoi(optarg); data/kafkacat-1.6.0/kafkacat.c:2066:9: [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 tmp[16]; data/kafkacat-1.6.0/kafkacat.c:2121:30: [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). in = fopen(argv[optind], "r"); data/kafkacat-1.6.0/kafkacat.h:117:15: [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 *pack[KC_MSG_FIELD_CNT]; data/kafkacat-1.6.0/tools.c:58:9: [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 errstr[512]; data/kafkacat-1.6.0/win32/wingetopt.c:182:6: [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 **) nargv)[pos] = nargv[cstart]; data/kafkacat-1.6.0/win32/wingetopt.c:184:6: [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 **)nargv)[cstart] = swap; data/kafkacat-1.6.0/avro.c:136: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). int len = strlen(errstr); data/kafkacat-1.6.0/format.c:90: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). strlen(conf.fmt[conf.fmt_cnt].str); data/kafkacat-1.6.0/format.c:157:48: [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). fmt_add(KC_FMT_STR, s, strlen(s)); data/kafkacat-1.6.0/json.c:35:63: [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). yajl_gen_string(G, (const unsigned char *)_s, strlen(_s)); \ data/kafkacat-1.6.0/json.c:136:60: [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). yajl_gen_verbatim(g, json, strlen(json)); data/kafkacat-1.6.0/json.c:167:60: [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). yajl_gen_verbatim(g, json, strlen(json)); data/kafkacat-1.6.0/json.c:228:28: [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). int blen = strlen(metadata->brokers[i].host); data/kafkacat-1.6.0/kafkacat.c:1054:17: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(features, "n/a", sizeof(features)); data/kafkacat-1.6.0/kafkacat.c:1332: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). if (!strncmp(str, "\\x", strlen("\\x"))) data/kafkacat-1.6.0/kafkacat.c:1333: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). delim = strtoul(str+strlen("\\x"), NULL, 16) & 0xff; data/kafkacat-1.6.0/kafkacat.c:1414: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). size_t srlen = strlen("schema.registry."); data/kafkacat-1.6.0/kafkacat.c:1444:38: [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(name, "topic.", strlen("topic."))) data/kafkacat-1.6.0/kafkacat.c:1447: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). strlen("topic."), data/kafkacat-1.6.0/kafkacat.c:1547: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). t = s + strlen(s) - 1; data/kafkacat-1.6.0/kafkacat.c:1564:41: [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). memmove(t, t+1, strlen(t+1)+1); /* overwrite \: */ data/kafkacat-1.6.0/kafkacat.c:1568:41: [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). memmove(t, t+1, strlen(t+1)+1); /* overwrite \= */ data/kafkacat-1.6.0/kafkacat.c:1761:49: [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(t, "key=", strlen("key="))) { data/kafkacat-1.6.0/kafkacat.c:1762:38: [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). t += strlen("key="); data/kafkacat-1.6.0/kafkacat.c:1764:58: [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 (!strncmp(t, "value=", strlen("value="))) { data/kafkacat-1.6.0/kafkacat.c:1765:38: [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). t += strlen("value="); data/kafkacat-1.6.0/kafkacat.c:1802:55: [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). conf.fixed_key_len = (size_t)(strlen(conf.fixed_key)); data/kafkacat-1.6.0/kafkacat.c:1821: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). conf.null_str_len = strlen(conf.null_str); data/kafkacat-1.6.0/kafkacat.c:2002: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). t = &conf.schema_registry_url[strlen(conf. data/kafkacat-1.6.0/win32/getdelim.c:87:21: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((ch = getc (fp)) == EOF) data/kafkacat-1.6.0/win32/wingetopt.c:218: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). current_argv_len = strlen(current_argv); data/kafkacat-1.6.0/win32/wingetopt.c:226:7: [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(long_options[i].name) == current_argv_len) { ANALYSIS SUMMARY: Hits = 81 Lines analyzed = 4861 in approximately 0.18 seconds (27643 lines/second) Physical Source Lines of Code (SLOC) = 3384 Hits@level = [0] 60 [1] 26 [2] 33 [3] 8 [4] 14 [5] 0 Hits@level+ = [0+] 141 [1+] 81 [2+] 55 [3+] 22 [4+] 14 [5+] 0 Hits/KSLOC@level+ = [0+] 41.6667 [1+] 23.9362 [2+] 16.253 [3+] 6.50118 [4+] 4.13712 [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.