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
This commit is contained in:
Holger Hans Peter Freyther 2013-07-04 20:14:10 +02:00
parent 047213b01e
commit 8d50600d7d
1 changed files with 1 additions and 0 deletions

View File

@ -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;
}