diff options
author | Peter Wu <peter@lekensteyn.nl> | 2019-01-19 00:32:49 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2019-01-19 07:08:43 +0000 |
commit | 5eb8edf1cbda6a2eea1aa7c101224f859bf31543 (patch) | |
tree | 65d3b7a0a1a2c764b8bb4a414e5cc234f2477901 /epan/diam_dict.l | |
parent | 7e7caaddf802b41c26eef0b61c87c231aec519be (diff) |
diam_dict.l,wimaxasncp_dict.l: fix -Werror=stringop-truncation
The given "len" is the size of the string in "txt" excluding the NUL
terminator. GCC 8.2.1+20181127-1 rightfully complains that strncpy will
not terminate the destination buffer.
Change-Id: I592c7c218cf07c13697de4e60f454326a93d1124
Reviewed-on: https://code.wireshark.org/review/31600
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/diam_dict.l')
-rw-r--r-- | epan/diam_dict.l | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/epan/diam_dict.l b/epan/diam_dict.l index 407004f77a..5126b9c337 100644 --- a/epan/diam_dict.l +++ b/epan/diam_dict.l @@ -664,13 +664,13 @@ append_to_buffer(const char* txt, unsigned len, DiamDict_scanner_state_t *statep statep->write_ptr = statep->strbuf; } - if ( (statep->len_strbuf + len) >= statep->size_strbuf ) { + if (statep->len_strbuf + len >= statep->size_strbuf) { statep->strbuf = (char*)g_realloc(statep->strbuf,statep->size_strbuf *= 2); statep->read_ptr = statep->strbuf; } statep->write_ptr = statep->strbuf + statep->len_strbuf; - strncpy(statep->write_ptr,txt,len); + memcpy(statep->write_ptr, txt, len + 1); statep->len_strbuf += len; } |