Skip to content

Commit

Permalink
Prevent crash on malformed Key Usage
Browse files Browse the repository at this point in the history
Key Usage bit strings longer than 2 bytes were inducing buffer overflow.

Thanks to Niklas Vogel for reporting this.
  • Loading branch information
ydahhrk committed Aug 6, 2024
1 parent 5689dea commit 939d988
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/object/certificate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,9 @@ handle_ku(ASN1_BIT_STRING *ku, unsigned char byte1)

unsigned char data[2];

if (ku->length == 0) {
return pr_val_err("%s bit string has no enabled bits.",
ext_ku()->name);
if (ku->length != 2 && ku->length != 1) {
return pr_val_err("Bogus %s length: %d",
ext_ku()->name, ku->length);
}

memset(data, 0, sizeof(data));
Expand Down

0 comments on commit 939d988

Please sign in to comment.