Change in osmo-pcu[master]: csn1: Extend CSN_SERIALIZE to allow 0 bit of length

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Jan 28 21:34:42 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/16997 )

Change subject: csn1: Extend CSN_SERIALIZE to allow 0 bit of length
......................................................................

csn1: Extend CSN_SERIALIZE to allow 0 bit of length

Port of wireshark.git 2f024256bf337400ef3a82fa75e6d48d5707e059.

>From c6ee558d3bb00bfd25cca7c534448bf60df3c7cf Mon Sep 17 00:00:00 2001
From: Sylvain Munaut <tnt at 246tNt.com>
Date: Sat, 4 Feb 2012 10:24:01 +0100
Subject: [PATCH 6/6] packet-csn: Extend CSN_SERIALIZE to allow 0 bit of length

In some coding there is no 'length' field at the top of a serialized
block, or it's more complex than a single field, in which case we
have to rely on the serialize decoder to consume the correct number
of bits.

We extend the CSN_SERIALIZE processing so that if a '0 bit' length
field is specified, then the length is not displayed and the
consumed bits by the serialize function is taken as the length
at posteriori.

The processing keeps the same behavior for any length > 0.

Change-Id: I9fadc99218594447001f7bb9943f4514b9877799
---
M src/csn1.cpp
1 file changed, 8 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/csn1.cpp b/src/csn1.cpp
index f7e9be0..4f761c7 100644
--- a/src/csn1.cpp
+++ b/src/csn1.cpp
@@ -548,15 +548,20 @@
         bit_offset += length_len;
         remaining_bits_len -= length_len;
 
-        csnStreamInit(&arT, bit_offset, length);
+        csnStreamInit(&arT, bit_offset, length > 0 ? length : remaining_bits_len);
         arT.direction = 1;
         LOGPC(DCSN1, LOGL_NOTICE, "ptr = %p | offset = %d | ", (void *)data, (int)pDescr->offset);
 	Status = serialize(&arT, vector, readIndex, pvDATA(data, pDescr->offset));
 
         if (Status >= 0)
         {
-          remaining_bits_len -= length;
-          bit_offset         += length;
+          if (length > 0) {
+            remaining_bits_len -= length;
+            bit_offset         += length;
+          } else {
+            remaining_bits_len = arT.remaining_bits_len;
+            bit_offset         = arT.bit_offset;
+          }
           pDescr++;
         }
         else

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/16997
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I9fadc99218594447001f7bb9943f4514b9877799
Gerrit-Change-Number: 16997
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200128/6d593148/attachment.htm>


More information about the gerrit-log mailing list