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 /plugins | |
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 'plugins')
-rw-r--r-- | plugins/epan/wimaxasncp/wimaxasncp_dict.l | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/plugins/epan/wimaxasncp/wimaxasncp_dict.l b/plugins/epan/wimaxasncp/wimaxasncp_dict.l index 3dc4dbf887..68caa80b1f 100644 --- a/plugins/epan/wimaxasncp/wimaxasncp_dict.l +++ b/plugins/epan/wimaxasncp/wimaxasncp_dict.l @@ -593,14 +593,13 @@ static void append_to_buffer(const gchar *txt, int len, WimaxasncpDict_scanner_s state->read_ptr = state->write_ptr = state->strbuf = (gchar *)g_malloc(state->size_strbuf); } - if ( (state->len_strbuf + len + 1) >= state->size_strbuf ) { + if (state->len_strbuf + len >= state->size_strbuf) { state->read_ptr = state->strbuf = (gchar *)g_realloc(state->strbuf,state->size_strbuf *= 2); } state->write_ptr = state->strbuf + state->len_strbuf; - strncpy(state->write_ptr,txt,len); + memcpy(state->write_ptr, txt, len + 1); state->len_strbuf += len; - state->strbuf[state->len_strbuf] = '\0'; } static size_t file_input(gchar *buf, size_t max, yyscan_t scanner) { |