From 3bbc240263363df164e58dcc9c13690ea85702a7 Mon Sep 17 00:00:00 2001 From: Ruchir Rastogi Date: Wed, 18 Dec 2019 13:43:05 -0800 Subject: [PATCH] Fix error checking in append_string Test: m -j Change-Id: Ifa806d5037acb17f83cbf45712e9795d6f56152f --- libstats/socket/stats_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstats/socket/stats_event.c b/libstats/socket/stats_event.c index 35081dc3f..cd4eb5fb3 100644 --- a/libstats/socket/stats_event.c +++ b/libstats/socket/stats_event.c @@ -142,7 +142,7 @@ static void append_byte_array(struct stats_event* event, uint8_t* buf, size_t si // Side-effect: modifies event->errors if buf is not properly null-terminated static void append_string(struct stats_event* event, const char* buf) { size_t size = strnlen(buf, MAX_EVENT_PAYLOAD); - if (event->errors) { + if (size == MAX_EVENT_PAYLOAD) { event->errors |= ERROR_STRING_NOT_NULL_TERMINATED; return; }