diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-07-04 20:14:10 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-07-04 20:14:10 +0200 |
commit | 8d50600d7d927a5c9f08c2a9573b6a45866dc602 (patch) | |
tree | 09d9424bdcd9d0278640f999d44e70f1aac933c0 | |
parent | 047213b01e786c9765460fccd5f394e93fc777f1 (diff) |
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
-rw-r--r-- | src/utils.c | 1 |
1 files changed, 1 insertions, 0 deletions
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; } |