CSN1: fix dissection of variable bitmaps

Change-Id: I3dbb2a4f8f7ea125e4f96e302ea33ff03706eb1b
Reviewed-on: https://code.wireshark.org/review/15674
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
Vincent Helfre 2016-06-01 11:37:00 +02:00 committed by Pascal Quantin
parent 575e4df4aa
commit b079151c6f
1 changed files with 9 additions and 28 deletions

View File

@ -1150,35 +1150,17 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
no_of_bits += pDescr->i; /* adjusted by offset */
if (no_of_bits > 0)
while (no_of_bits > 0)
{
proto_tree_add_bits_item(tree, *(pDescr->hf_ptr), tvb, bit_offset, 1, ENC_BIG_ENDIAN);
bit_offset++;
no_of_bits--;
remaining_bits_len--;
if (remaining_bits_len < 0)
{
return ProcessError(tree, ar->pinfo, tvb, bit_offset, CSN_ERROR_NEED_MORE_BITS_TO_UNPACK, &ei_csn1_more_bits_to_unpack, pDescr);
}
{ /* extract bits */
guint8* t_pui8 = pui8DATA(data, pDescr->offset);
gint16 nB1 = no_of_bits & 0x07;/* no_of_bits Mod 8 */
if (nB1 > 0)
{ /* take care of the first byte - it will be right aligned */
*t_pui8++ = tvb_get_bits8(tvb, bit_offset, nB1);
no_of_bits -= nB1;
bit_offset += nB1; /* (nB1 is no_of_bits Mod 8) */
remaining_bits_len -= nB1;
}
/* remaining no_of_bits is a multiple of 8 or 0 */
while (no_of_bits > 0)
{
*t_pui8++ = tvb_get_bits8(tvb, bit_offset, 8);
no_of_bits -= 8;
remaining_bits_len -= 8;
}
}
}
pDescr++;
break;
@ -1278,11 +1260,6 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
if (count > 0)
{
if (remaining_bits_len < 0)
{
return ProcessError(tree, ar->pinfo, tvb, bit_offset, CSN_ERROR_NEED_MORE_BITS_TO_UNPACK, &ei_csn1_more_bits_to_unpack, pDescr);
}
pui8 = pui8DATA(data, pDescr->offset);
while (count > 0)
@ -1290,8 +1267,12 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
proto_tree_add_bits_item(tree, *(pDescr->hf_ptr), tvb, bit_offset, 8, ENC_BIG_ENDIAN);
*pui8++ = tvb_get_bits8(tvb, bit_offset, 8);
bit_offset += 8;
remaining_bits_len -= 8;
count--;
remaining_bits_len -= 8;
if (remaining_bits_len < 0)
{
return ProcessError(tree, ar->pinfo, tvb, bit_offset, CSN_ERROR_NEED_MORE_BITS_TO_UNPACK, &ei_csn1_more_bits_to_unpack, pDescr);
}
}
}