Skip to content

Commit c3b8bd5

Browse files
committed
in_kafka: add NULL check for SASL mechanism allocation
Add NULL check after flb_sds_create() when allocating SASL mechanism string during AWS MSK IAM setup to prevent crashes on allocation failure. Signed-off-by: Arbin <[email protected]>
1 parent 2264d52 commit c3b8bd5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

plugins/in_kafka/in_kafka.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ static int in_kafka_init(struct flb_input_instance *ins,
284284
flb_input_set_property(ins, "rdkafka.sasl.mechanism", "OAUTHBEARER");
285285
flb_sds_destroy(ctx->sasl_mechanism);
286286
ctx->sasl_mechanism = flb_sds_create("OAUTHBEARER");
287+
if (!ctx->sasl_mechanism) {
288+
flb_plg_error(ins, "failed to allocate SASL mechanism string");
289+
flb_free(ctx);
290+
return -1;
291+
}
287292

288293
/* Ensure security protocol is set */
289294
conf = flb_input_get_property("rdkafka.security.protocol", ins);

0 commit comments

Comments
 (0)