Change in osmo-pcu[master]: csn1: fix csnStreamDecoder(): always keep remaining_bits_len updated

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
Mon Feb 17 21:58:42 UTC 2020


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

Change subject: csn1: fix csnStreamDecoder(): always keep remaining_bits_len updated
......................................................................

csn1: fix csnStreamDecoder(): always keep remaining_bits_len updated

Found while doing differential analysis (comparison against the
original implementation from Wireshark).

Change-Id: I9f7fa9c3f2f4ff5213dded930cee7ec509b9d799
---
M src/csn1.c
1 file changed, 4 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/csn1.c b/src/csn1.c
index a766bd3..31b8e00 100644
--- a/src/csn1.c
+++ b/src/csn1.c
@@ -656,8 +656,6 @@
             guint8 no_of_bits = (guint8) pDescr->i;
             if (remaining_bits_len >= no_of_bits)
             {
-              remaining_bits_len -= no_of_bits;
-
               if (no_of_bits <= 8)
               {
 		guint8 ui8 = bitvec_read_field(vector, readIndex,  no_of_bits);
@@ -689,6 +687,7 @@
               return ProcessError(readIndex,"csnStreamDecoder", CSN_ERROR_GENERAL, pDescr);
             }
 
+            remaining_bits_len -= no_of_bits;
             bit_offset += no_of_bits;
             pDescr++;
             break;
@@ -731,6 +730,7 @@
               return ProcessError(readIndex,"csnStreamDecoder", CSN_ERROR_NEED_MORE_BITS_TO_UNPACK, pDescr);
             }
 
+            remaining_bits_len -= no_of_bits;
             bit_offset += no_of_bits;
             pDescr++;
             break;
@@ -759,6 +759,7 @@
               return ProcessError(readIndex,"csnStreamDecoder", CSN_ERROR_NEED_MORE_BITS_TO_UNPACK, pDescr);
             }
 
+            remaining_bits_len -= no_of_bits;
             bit_offset += no_of_bits;
             pDescr++;
             break;
@@ -1310,6 +1311,7 @@
         LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , bitvec_get_uint(vector, 1));
 
         /* existNextElement() returned FALSE, 1 bit consumed */
+        remaining_bits_len--;
         bit_offset++;
 
         /* Store the counted number of elements of the array */

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I9f7fa9c3f2f4ff5213dded930cee7ec509b9d799
Gerrit-Change-Number: 17195
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200217/5e7f6383/attachment.htm>


More information about the gerrit-log mailing list