diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-11 14:22:56 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-11 14:22:56 +0000 |
commit | d220318fcbc951056f5e1a3e018d295d580b5a45 (patch) | |
tree | 4fe135b5dd49699cdbe0f457365f3355a80770dc /lib/libssl | |
parent | 68e11f76b827b63c9e6fa803630ad7f5cb86a60c (diff) |
In asn1_get_length(), tolerate leading zeroes in BER encoding.
OpenSSL PR #2746 via OpenSSL trunk
Diffstat (limited to 'lib/libssl')
-rw-r--r-- | lib/libssl/src/crypto/asn1/asn1_lib.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/libssl/src/crypto/asn1/asn1_lib.c b/lib/libssl/src/crypto/asn1/asn1_lib.c index b5f3f78b940..d851339753e 100644 --- a/lib/libssl/src/crypto/asn1/asn1_lib.c +++ b/lib/libssl/src/crypto/asn1/asn1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_lib.c,v 1.30 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: asn1_lib.c,v 1.31 2014/07/11 14:22:55 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -174,15 +174,18 @@ asn1_get_length(const unsigned char **pp, int *inf, long *rl, int max) *inf = 0; i= *p & 0x7f; if (*(p++) & 0x80) { + if (max < (int)i) + return (0); + /* skip leading zeroes */ + while (i && *p == 0) { + p++; + i--; + } if (i > sizeof(long)) return 0; - if (max-- == 0) - return (0); while (i-- > 0) { ret <<= 8L; ret |= *(p++); - if (max-- == 0) - return (0); } } else ret = i; |