pespin has uploaded this change for review.

View Change

bits: Fix osmo_pbit2ubit() reading extra input byte on num_bits%8==0

For instance, if num_bits was 0, it would read in[0], which is
unexpected.

Related: OS#7052
Reported-By: Adam Bedard <adam.bedard@gmail.com>
Change-Id: I3ec32631440f3df48627eac3ec4cefae32ef7244
---
M src/core/bits.c
1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/36/43236/1
diff --git a/src/core/bits.c b/src/core/bits.c
index a4c0970..fc41d4a 100644
--- a/src/core/bits.c
+++ b/src/core/bits.c
@@ -148,7 +148,7 @@
ubit_t *cur = out;
ubit_t *limit = out + num_bits;

- for (i = 0; i < (num_bits/8)+1; i++) {
+ for (i = 0; i < ((num_bits + 7) / 8); i++) {
pbit_t byte = in[i];
*cur++ = (byte >> 7) & 1;
if (cur >= limit)

To view, visit change 43236. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I3ec32631440f3df48627eac3ec4cefae32ef7244
Gerrit-Change-Number: 43236
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>