PROFINET DCP: fix dissection of an empty DHCP option

Bug: 15774
Change-Id: Ief2588e5d6f43da708ef071a4490f5f881268820
Reviewed-on: https://code.wireshark.org/review/33186
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Mehmet Oguz Sakaoglu <mehmet.oguz.mnz@gmail.com>
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
This commit is contained in:
Pascal Quantin 2019-05-13 22:55:46 +02:00
parent 7e8a58e1e1
commit fed0e7c2d0
1 changed files with 15 additions and 14 deletions

View File

@ -908,24 +908,25 @@ dissect_PNDCP_Suboption_DHCP(tvbuff_t *tvb, int offset, packet_info *pinfo,
}
offset += 1;//SuboptionDHCP
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp_parameter_length, &dhcpparameterlength);
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp_parameter_data, &dhcpparameterdata);
if (dhcpparameterlength == 1) {
if (dhcpparameterdata == 1) {
proto_item_append_text(block_item, ", Client-ID: MAC Address");
if (dhcpparameterlength > 0) {
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp_parameter_data, &dhcpparameterdata);
if (dhcpparameterlength == 1) {
if (dhcpparameterdata == 1) {
proto_item_append_text(block_item, ", Client-ID: MAC Address");
}
else {
proto_item_append_text(block_item, ", Client-ID: Name of Station");
}
}
else {
proto_item_append_text(block_item, ", Client-ID: Name of Station");
proto_item_append_text(block_item, ", Client-ID: Arbitrary");
arbitraryclientID = (char *)wmem_alloc(wmem_packet_scope(), dhcpparameterlength);
tvb_memcpy(tvb, (guint8 *)arbitraryclientID, offset, dhcpparameterlength - 1);
arbitraryclientID[dhcpparameterlength - 1] = '\0';
proto_tree_add_string(tree, hf_pn_dcp_suboption_dhcp_arbitrary_client_id, tvb, offset, dhcpparameterlength - 1, arbitraryclientID);
offset += dhcpparameterlength;
}
}
else {
proto_item_append_text(block_item, ", Client-ID: Arbitrary");
arbitraryclientID = (char *)wmem_alloc(wmem_packet_scope(), dhcpparameterlength);
tvb_memcpy(tvb, (guint8 *)arbitraryclientID, offset, 5);
arbitraryclientID[dhcpparameterlength - 1] = '\0';
proto_tree_add_string(tree, hf_pn_dcp_suboption_dhcp_arbitrary_client_id, tvb, offset, dhcpparameterlength - 1, arbitraryclientID);
offset += dhcpparameterlength;
}
break;
case PNDCP_SUBOPTION_DHCP_CONTROL_FOR_ADDRESS_RES:
pn_append_info(pinfo, dcp_item, ", Control DHCP for address resolution");