From 90dafa467ce6dd955ea28b8ccc69761fb4572ce6 Mon Sep 17 00:00:00 2001 From: Bosko Milekic Date: Thu, 1 Nov 2012 14:51:55 -0400 Subject: [PATCH] Comment: strncpy() does not null terminate if it fill all bytes up to len. This fixes this issue. (reported by: andoma) --- examples/rdkafka_example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rdkafka_example.c b/examples/rdkafka_example.c index e88653c953..589c5e477f 100644 --- a/examples/rdkafka_example.c +++ b/examples/rdkafka_example.c @@ -147,7 +147,7 @@ int main (int argc, char **argv) { while (run && (fgets(buf, sizeof(buf), stdin))) { int len = strlen(buf); char *opbuf = malloc(len + 1); - strncpy(opbuf, buf, len); + strncpy(opbuf, buf, len + 1); /* Send/Produce message. */ rd_kafka_produce(rk, topic, partition, RD_KAFKA_OP_F_FREE, opbuf, len);