diff options
Diffstat (limited to '')
-rw-r--r-- | common/convert.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/convert.c b/common/convert.c index c946b81b1..d3e8b642e 100644 --- a/common/convert.c +++ b/common/convert.c @@ -194,7 +194,9 @@ hex2str (const char *hexstring, char *buffer, size_t bufsize, size_t *buflen) ; if (*s && (!isascii (*s) || !isspace (*s)) ) return NULL; /* Not followed by Nul or white space. */ - need_nul = !(s[-2] == '0' && s[-1] == '0'); + /* We need to append a nul character. However we don't want that if + the hexstring already ends with "00". */ + need_nul = ((s == hexstring) || !(s[-2] == '0' && s[-1] == '0')); if (need_nul) count++; |