summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/binarybuffer.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c
index 7d41dc73..acc8237e 100644
--- a/src/helper/binarybuffer.c
+++ b/src/helper/binarybuffer.c
@@ -101,6 +101,12 @@ u8* buf_cpy(u8 *from, u8 *to, int size)
for (i = 0; i < num_bytes; i++)
to[i] = from[i];
+
+ /* mask out bits that don't belong to the buffer */
+ if (size % 8)
+ {
+ to[size / 8] &= (0xff >> (8 - (size % 8)));
+ }
return to;
}