COAP: ensure that key_token is always initialized

Even when the token length is 0.

Bug: 12771
Change-Id: I0d77f0411fe90a6702d1f23ba9cd4b61433a5995
Reviewed-on: https://code.wireshark.org/review/17194
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Pascal Quantin 2016-08-20 21:03:02 +02:00 committed by Anders Broman
parent 8f98f7ce67
commit 0a9e842649
1 changed files with 1 additions and 1 deletions

View File

@ -873,13 +873,13 @@ dissect_coap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d
coap_uri_str_strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), 0, 1024);
coap_uri_query_strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), 0, 1024);
coap_token_str = NULL;
memset(&key_token[0], 0, sizeof(key_token));
if (token_len > 0)
{
coap_token_str = tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, offset, token_len, ' ');
proto_tree_add_item(coap_tree, hf_coap_token,
tvb, offset, token_len, ENC_NA);
memset(&key_token[0], 0, sizeof(key_token));
if ( token_len > 8 ) {
/* The token is limited to a maximum length of 8 but the bits in the
* protocol specifies 4 bits. Use 8 bytes at most. */