mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
common: Protect against a theoretical integer overflow in tlv.c
* common/tlv.c (parse_ber_header): Protect agains integer overflow. -- Although there is no concrete case where we use the (nhdr + length), it is better to protect against this already here.
This commit is contained in:
parent
64002ffdfc
commit
94d13f53a3
@ -222,6 +222,11 @@ parse_ber_header (unsigned char const **buffer, size_t *size,
|
|||||||
*r_length = len;
|
*r_length = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*r_length > *r_nhdr && (*r_nhdr + *r_length) < *r_length)
|
||||||
|
{
|
||||||
|
return gpg_err_make (default_errsource, GPG_ERR_EOVERFLOW);
|
||||||
|
}
|
||||||
|
|
||||||
/* Without this kludge some example certs can't be parsed. */
|
/* Without this kludge some example certs can't be parsed. */
|
||||||
if (*r_class == CLASS_UNIVERSAL && !*r_tag)
|
if (*r_class == CLASS_UNIVERSAL && !*r_tag)
|
||||||
*r_length = 0;
|
*r_length = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user