From 809a22d449637972d3dca46dc18ce7bb6ae79e3d Mon Sep 17 00:00:00 2001 From: eeff <33566201+eeff@users.noreply.github.com> Date: Thu, 14 Apr 2022 12:58:11 +0800 Subject: [PATCH] fix: ekuiper plugin send json data without terminating null byte --- plugins/ekuiper/read_write.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/ekuiper/read_write.c b/plugins/ekuiper/read_write.c index 28368bee..f38b92e5 100644 --- a/plugins/ekuiper/read_write.c +++ b/plugins/ekuiper/read_write.c @@ -46,7 +46,7 @@ void send_data(neu_plugin_t *plugin, neu_request_t *req) } nng_msg *msg = NULL; - size_t json_len = strlen(json_str) + 1; // for terminating null byte + size_t json_len = strlen(json_str); rv = nng_msg_alloc(&msg, json_len); if (0 != rv) { log_error("nng cannot allocate msg"); @@ -54,7 +54,7 @@ void send_data(neu_plugin_t *plugin, neu_request_t *req) return; } - memcpy(nng_msg_body(msg), json_str, json_len); + memcpy(nng_msg_body(msg), json_str, json_len); // no null byte rv = nng_sendmsg(plugin->sock, msg, 0); // TODO: use aio to send message if (0 != rv) { log_error("nng cannot send msg");