Skip to content

Commit 47057d7

Browse files
ethan-thompsonalandekok
authored andcommitted
encode OID subidentifier value 0 as single 0x00 byte
Signed-off-by: ethan-thompson <ethan.thompson@networkradius.com>
1 parent 47c30d7 commit 47057d7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/protocols/der/encode.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ static ssize_t fr_der_encode_oid_from_value(fr_dbuff_t *dbuff, uint64_t value, u
590590
{
591591
fr_dbuff_t our_dbuff;
592592
int i;
593+
bool wrote = false;
593594
uint64_t oid;
594595

595596
/*
@@ -632,12 +633,16 @@ static ssize_t fr_der_encode_oid_from_value(fr_dbuff_t *dbuff, uint64_t value, u
632633
for (i = 63; i >= 0; i -= 7) {
633634
uint8_t more, part;
634635

636+
/*
637+
* Skip leading zeroes, but not intermediate ones.
638+
*/
635639
part = (oid >> i) & 0x7f;
636-
if (!part) continue;
640+
if (!part && !wrote && (i > 0)) continue;
637641

638642
more = ((uint8_t) (i > 0)) << 7;
639643

640644
FR_DBUFF_IN_RETURN(&our_dbuff, (uint8_t) (more | part));
645+
wrote = true;
641646
}
642647

643648
(*count)++;

0 commit comments

Comments
 (0)