aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-csn1.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/epan/dissectors/packet-csn1.c b/epan/dissectors/packet-csn1.c
index b54b672a5f..ddba95211c 100644
--- a/epan/dissectors/packet-csn1.c
+++ b/epan/dissectors/packet-csn1.c
@@ -1070,7 +1070,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
case CSN_NEXT_EXIST:
{
- guint8 fExist;
+ guint8 isnull;
pui8 = pui8DATA(data, pDescr->offset);
@@ -1089,18 +1089,30 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
/* the "regular" M_NEXT_EXIST description element */
proto_tree_add_bits_item(tree, *(pDescr->hf_ptr), tvb, bit_offset, 1, ENC_BIG_ENDIAN);
- fExist = 0x00;
+ isnull = 1;
if (tvb_get_bits8(tvb, bit_offset, 1))
{
- fExist = 0x01;
+ if (remaining_bits_len == 1)
+ {
+ /* If { 1 < end > } and all next items may be null, store it as { 0 } */
+ const CSN_DESCR* pDescrNext = pDescr + 1;
+ guint8 i;
+ for (i = 0; i < pDescr->i; i++, pDescrNext++)
+ {
+ if (!pDescrNext->may_be_null)
+ isnull = 0;
+ }
+ } else {
+ isnull = 0;
+ }
}
- *pui8 = fExist;
+ *pui8 = !isnull;
remaining_bits_len --;
bit_offset++;
- if (fExist == 0)
+ if (isnull)
{ /* Skip 'i' entries */
pDescr += pDescr->i;
}
@@ -1111,7 +1123,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
case CSN_NEXT_EXIST_LH:
{
- guint8 fExist;
+ guint8 isnull;
pui8 = pui8DATA(data, pDescr->offset);
/* this if-statement represents the M_NEXT_EXIST_OR_NULL_LH description element */
@@ -1129,14 +1141,29 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
/* the "regular" M_NEXT_EXIST_LH description element */
proto_tree_add_bits_item(tree, *(pDescr->hf_ptr), tvb, bit_offset, 1, ENC_BIG_ENDIAN);
- fExist = tvb_get_masked_bits8(tvb, bit_offset, 1);
+ isnull = 1;
+ if (tvb_get_masked_bits8(tvb, bit_offset, 1))
+ {
+ if (remaining_bits_len == 1) {
+ /* If { 1 < end > } and all next items may be null, store it as { 0 } */
+ const CSN_DESCR* pDescrNext = pDescr + 1;
+ guint8 i;
+ for (i = 0; i < pDescr->i; i++, pDescrNext++)
+ {
+ if (!pDescrNext->may_be_null)
+ isnull = 0;
+ }
+ } else {
+ isnull = 0;
+ }
+ }
- *pui8++ = fExist;
+ *pui8++ = !isnull;
remaining_bits_len --;
bit_offset++;
- if (fExist == 0)
+ if (isnull)
{ /* Skip 'i' entries */
pDescr += pDescr->i;
}