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.orglaforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-pcu/+/14481 )
Change subject: decompress_crbb: add length argument for search_runlen
......................................................................
decompress_crbb: add length argument for search_runlen
search_runlen() must know the exact size in bits when parsing
the bits otherwise it read over the buffer.
Fixes testcase #7 which was wrongly decoded.
Change-Id: Ie34a0651e7e7efea4e9ecff1e3a467588113cf47
---
M src/egprs_rlc_compression.cpp
M tests/bitcomp/BitcompTest.cpp
M tests/bitcomp/BitcompTest.err
3 files changed, 14 insertions(+), 14 deletions(-)
Approvals:
laforge: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/egprs_rlc_compression.cpp b/src/egprs_rlc_compression.cpp
index 014e930..8f4fd87 100644
--- a/src/egprs_rlc_compression.cpp
+++ b/src/egprs_rlc_compression.cpp
@@ -449,6 +449,7 @@
/* Calculate runlength of a codeword
* \param root[in] Root of Ones or Zeros tree
* \param bmbuf[in] Received compressed bitmap buf
+ * \param length[in] Length of bitmap buf in bits
* \param bit_pos[in] The start bit pos to read codeword
* \param len_codewd[in] Length of code word
* \param rlen[out] Calculated run length
@@ -456,6 +457,7 @@
static int search_runlen(
egprs_compress_node *root,
const uint8_t *bmbuf,
+ uint8_t length,
uint8_t bit_pos,
uint8_t *len_codewd,
uint16_t *rlen)
@@ -469,6 +471,9 @@
while (iter->run_length == -1) {
if ((!iter->left) && (!iter->right))
return -1;
+ if (bit_pos >= length)
+ return -1;
+
/* get the bit value at the bitpos and put it in right most of dir */
dir = (bmbuf[bit_pos/8] >> (7 - (bit_pos & 0x07))) & 0x01;
bit_pos++;
@@ -498,7 +503,7 @@
const uint8_t *orig_crbb_buf,
bitvec *dest)
{
-
+ int8_t remaining_bmap_len = compress_bmap_len;
uint8_t bit_pos = 0;
uint8_t data;
egprs_compress_node *list = NULL;
@@ -509,7 +514,7 @@
int rc = 0;
egprs_compress *compress = instance();
- while (compress_bmap_len > 0) {
+ while (remaining_bmap_len > 0) {
if (start) {
data = 0xff;
list = compress->ones_list;
@@ -517,7 +522,7 @@
data = 0x00;
list = compress->zeros_list;
}
- rc = search_runlen(list, orig_crbb_buf,
+ rc = search_runlen(list, orig_crbb_buf, compress_bmap_len,
bit_pos, &nbits, &run_length);
if (rc == -1)
return -1;
@@ -525,6 +530,7 @@
if (run_length < 64)
start = !start;
cbmaplen = cbmaplen + run_length;
+
/* put run length of Ones in uncompressed bitmap */
while (run_length != 0) {
if (run_length > 8) {
@@ -536,7 +542,7 @@
}
}
bit_pos = bit_pos + nbits;
- compress_bmap_len = compress_bmap_len - nbits;
+ remaining_bmap_len = remaining_bmap_len - nbits;
}
return 0;
}
diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp
index 3fd3b1a..14246fe 100644
--- a/tests/bitcomp/BitcompTest.cpp
+++ b/tests/bitcomp/BitcompTest.cpp
@@ -91,14 +91,13 @@
.ucmp_len = 90,
.expect_rc = 0,
},
- /* TODO: previously marked as "Invalid inputs" but succeeds */
+ /* Invalid inputs */
{ .crbb_len = 18, .cc = 1,
.crbb_data = {0x1E, 0x70, 0xc0},
.ucmp_data = {0xb0, 0x00, 0x00},
.ucmp_len = 19,
- .expect_rc = 0,
+ .expect_rc = -1,
},
- /* Invalid inputs */
{ .crbb_len = 14, .cc = 1,
.crbb_data = {0x00, 0x1E, 0x7c},
.ucmp_data = {0x0},
diff --git a/tests/bitcomp/BitcompTest.err b/tests/bitcomp/BitcompTest.err
index 0642845..0c9bc66 100644
--- a/tests/bitcomp/BitcompTest.err
+++ b/tests/bitcomp/BitcompTest.err
@@ -108,13 +108,8 @@
Run_length = 1
Run_length = 1
Run_length = 2
-Run_length = 15
-rc = 0
-
-expected data = b0 00 00
-expected len = 19
-decoded data = b0 00 00
-decoded len = 19
+rc = -1
+Failed to decode CRBB: length 18, data 1e 70 c0
Test:8
Tree based decoding:
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/14481
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Ie34a0651e7e7efea4e9ecff1e3a467588113cf47
Gerrit-Change-Number: 14481
Gerrit-PatchSet: 3
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
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/20190624/d16cdd2e/attachment.htm>