Skip to content

Commit 3fef07c

Browse files
committed
also clear bits in der_decode_raw_bit_string()
1 parent 1d20c32 commit 3fef07c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/pk/asn1/der/bit/der_decode_raw_bit_string.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifdef LTC_DER
1818

1919
#define SETBIT(v, n) (v=((unsigned char)(v) | (1U << (unsigned char)(n))))
20+
#define CLRBIT(v, n) (v=((unsigned char)(v) & ~(1U << (unsigned char)(n))))
2021

2122
/**
2223
Store a BIT STRING
@@ -86,6 +87,8 @@ int der_decode_raw_bit_string(const unsigned char *in, unsigned long inlen,
8687
for (y = 0; y < blen; y++) {
8788
if (in[x] & (1 << (7 - (y & 7)))) {
8889
SETBIT(out[y/8], 7-(y%8));
90+
} else {
91+
CLRBIT(out[y/8], 7-(y%8));
8992
}
9093
if ((y & 7) == 7) {
9194
++x;

0 commit comments

Comments
 (0)