From faee34f1a0fba23d9ff9cf976663d566b5147e98 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 18 May 2021 14:00:35 -0400 Subject: [PATCH] TT#14008 fix rand_hex_string usage rand_hex_string() writes a terminated null byte, therefore the buffer must be larger by one byte. Change-Id: Ieca67754d67fd7e5f1c94b07ffc8d0de428f552a --- daemon/control_ng.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/control_ng.c b/daemon/control_ng.c index 7d1420ed5..36dfed003 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -589,10 +589,10 @@ fail: static void notify_tcp_client(gpointer key, gpointer value, gpointer user_data) { struct streambuf_stream *s = (struct streambuf_stream *)value; str *to_send = (str *)user_data; - char cookie_buf[16]; - str cookie = STR_CONST_INIT_LEN(cookie_buf, sizeof(cookie_buf)); + char cookie_buf[17]; + str cookie = STR_CONST_INIT(cookie_buf); - rand_hex_str(cookie_buf, sizeof(cookie_buf) / 2); + rand_hex_str(cookie_buf, cookie.len / 2); control_ng_send(&cookie, to_send, &s->sock.remote, &s->sock); }