From 8d50600d7d927a5c9f08c2a9573b6a45866dc602 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 4 Jul 2013 20:14:10 +0200 Subject: get_value_string: Null terminate after the call to snprintf It is impossible that the snprintf will fill the entire namebuf but just follow the idiom to make sure it is null terminated. Related: Coverity CID 1040676 --- src/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils.c b/src/utils.c index c36979c9..5874077c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -31,6 +31,7 @@ const char *get_value_string(const struct value_string *vs, uint32_t val) } snprintf(namebuf, sizeof(namebuf), "unknown 0x%x", val); + namebuf[sizeof(namebuf) - 1] = '\0'; return namebuf; } -- cgit v1.2.3