Skip to content

Commit

Permalink
Comment: strncpy() does not null terminate if it fill all bytes up to…
Browse files Browse the repository at this point in the history
… len. This fixes this issue. (reported by: andoma)
  • Loading branch information
Bosko Milekic committed Nov 1, 2012
1 parent bc92100 commit 90dafa4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/rdkafka_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 90dafa4

Please sign in to comment.