Skip to content

Commit

Permalink
der/asn1: limit recursion
Browse files Browse the repository at this point in the history
Limit the number of recursive calls in the DER/ASN.1 decoder to avoid
stack overflows.

Found using AFL.
  • Loading branch information
victorjulien committed Jul 13, 2017
1 parent 257db74 commit 53d8e29
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/util-decode-der.c
Expand Up @@ -139,6 +139,11 @@ static Asn1Generic * DecodeAsn1DerGeneric(const unsigned char *buffer,
Asn1Generic *child;
uint8_t el_type;

/* refuse excessive recursion */
if (unlikely(depth == 255)) {
return NULL;
}

el.cls = (d_ptr[0] & 0xc0) >> 6;
el.pc = (d_ptr[0] & 0x20) >> 5;
el.tag = (d_ptr[0] & 0x1f);
Expand Down

0 comments on commit 53d8e29

Please sign in to comment.