Skinny: do not try to create a wmem_strbuf whose size is bigger than the max size allowed

While we are at it, fix errors spotted by the pre-commit tools/SkinnyProtocolOptimized

Bug: 10409
Change-Id: Ic84632e0563f801239603534121e3487cf0d6d24
Reviewed-on: https://code.wireshark.org/review/3861
Reviewed-by: Evan Huus <eapache@gmail.com>
This commit is contained in:
Pascal Quantin 2014-08-26 13:01:24 +02:00 committed by Evan Huus
parent 338f6aca64
commit 7836a714ab
4 changed files with 8 additions and 8 deletions

View File

@ -2255,7 +2255,7 @@ dissect_skinny_ipv4or6(ptvcursor_t *cursor, int hfindex_ipv4, int hfindex_ipv6,
src_addr.data = (guint16 *)&IPv6;
tvb_get_ipv6(tvb, offset, &IPv6);
rtp_add_address(pinfo, &src_addr, tvb_get_letohl(tvb, offset), 0, "Skinny", pinfo->fd->num, is_video, NULL);
ptvcursor_add(cursor, hfindex_ipv6, 16, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hfindex_ipv6, 16, ENC_NA);
} else {
/* Invalid : skip over ipv6 space completely */
ptvcursor_advance(cursor, 16);
@ -2291,7 +2291,7 @@ dissect_skinny_displayLabel(ptvcursor_t *cursor, int hfindex, guint32 length, gu
return;
}
wmem_new = wmem_strbuf_sized_new(wmem_packet_scope(), strlen(disp_string), maxlength);
wmem_new = wmem_strbuf_sized_new(wmem_packet_scope(), 0, maxlength);
while (*disp_string) {
replacestr = NULL;
@ -2376,7 +2376,7 @@ handle_RegisterMessage(ptvcursor_t *cursor, packet_info * pinfo _U_)
ptvcursor_advance(cursor, 12 - 6);
ptvcursor_add(cursor, hf_skinny_ipV4AddressScope, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_maxNumberOfLines, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stationIpV6Addr, 16, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_skinny_stationIpV6Addr, 16, ENC_NA);
ptvcursor_add(cursor, hf_skinny_ipV6AddressScope, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_firmwareLoadName, 32, ENC_ASCII|ENC_NA);
}
@ -8951,7 +8951,7 @@ proto_register_skinny(void)
{ &hf_skinny_stationIpV6Addr,
{
"stationIpV6Addr", "skinny.stationIpV6Addr", FT_IPv6, BASE_NONE, NULL, 0x0,
"IPv5 Address", HFILL }},
"IPv6 Address", HFILL }},
{ &hf_skinny_stationIpV6Addr_ipv4,
{
"stationIpV6Addr IPv4 Address", "skinny.stationIpV6Addr.ipv4", FT_IPv4, BASE_NONE, NULL, 0x0,

View File

@ -260,7 +260,7 @@ dissect_skinny_ipv4or6(ptvcursor_t *cursor, int hfindex_ipv4, int hfindex_ipv6,
src_addr.data = (guint16 *)&IPv6;
tvb_get_ipv6(tvb, offset, &IPv6);
rtp_add_address(pinfo, &src_addr, tvb_get_letohl(tvb, offset), 0, "Skinny", pinfo->fd->num, is_video, NULL);
ptvcursor_add(cursor, hfindex_ipv6, 16, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hfindex_ipv6, 16, ENC_NA);
} else {
/* Invalid : skip over ipv6 space completely */
ptvcursor_advance(cursor, 16);
@ -296,7 +296,7 @@ dissect_skinny_displayLabel(ptvcursor_t *cursor, int hfindex, guint32 length, gu
return;
}
wmem_new = wmem_strbuf_sized_new(wmem_packet_scope(), strlen(disp_string), maxlength);
wmem_new = wmem_strbuf_sized_new(wmem_packet_scope(), 0, maxlength);
while (*disp_string) {
replacestr = NULL;

View File

@ -479,7 +479,7 @@
<ether comment="Mac Address" longcomment="Ethernet/Mac Address" name="macAddress" size="12" type="ether"/>
<integer comment="IPv4 Address Scope" name="ipV4AddressScope" type="uint32"/>
<integer comment="Maximum number of lines" name="maxNumberOfLines" type="uint32"/>
<ip comment="IPv5 Address" endianness="big" name="stationIpV6Addr" type="ipv6"/>
<ip comment="IPv6 Address" endianness="big" name="stationIpV6Addr" type="ipv6"/>
<integer comment="IPv6 Address Scope" name="ipV6AddressScope" type="uint32"/>
<string comment="Firmware Load Name" name="firmwareLoadName" size="32" type="char"/>
</fields>

View File

@ -606,7 +606,7 @@ def xml2obj(src):
if self.type == "ipv4":
return self.indent_out('ptvcursor_add(cursor, hf_skinny_%s, 4, ENC_BIG_ENDIAN);\n' %self.name)
else:
return self.indent_out('ptvcursor_add(cursor, hf_skinny_%s, 16, ENC_BIG_ENDIAN);\n' %self.name)
return self.indent_out('ptvcursor_add(cursor, hf_skinny_%s, 16, ENC_NA);\n' %self.name)
class Ipv4or6(DataNode):
def __init__(self):