[openssl-commits] [openssl] OpenSSL_1_1_0-stable update
Andy Polyakov
appro at openssl.org
Sun Apr 30 13:22:49 UTC 2017
The branch OpenSSL_1_1_0-stable has been updated
via d3d51adc87137fec7472a7e741490622ce725671 (commit)
from 913d3a644edafee2a20c620e8625e9f3be49f643 (commit)
- Log -----------------------------------------------------------------
commit d3d51adc87137fec7472a7e741490622ce725671
Author: Andy Polyakov <appro at openssl.org>
Date: Fri Apr 28 10:06:35 2017 +0200
asn1/a_int.c: fix "next negative minimum" corner case in c2i_ibuf.
"Next" refers to negative minimum "next" to one presentable by given
number of bytes. For example, -128 is negative minimum presentable by
one byte, and -256 is "next" one.
Thanks to Kazuki Yamaguchi for report, GH#3339
Reviewed-by: Rich Salz <rsalz at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(cherry picked from commit 1e93d619b78832834ae32f5c0c1b0e466267f72d)
-----------------------------------------------------------------------
Summary of changes:
crypto/asn1/a_int.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/crypto/asn1/a_int.c b/crypto/asn1/a_int.c
index e154343..217650a 100644
--- a/crypto/asn1/a_int.c
+++ b/crypto/asn1/a_int.c
@@ -167,10 +167,21 @@ static size_t c2i_ibuf(unsigned char *b, int *pneg,
}
return 1;
}
- if (p[0] == 0 || p[0] == 0xFF)
+
+ pad = 0;
+ if (p[0] == 0) {
pad = 1;
- else
- pad = 0;
+ } else if (p[0] == 0xFF) {
+ size_t i;
+
+ /*
+ * Special case [of "one less minimal negative" for given length]:
+ * if any other bytes non zero it was padded, otherwise not.
+ */
+ for (pad = 0, i = 1; i < plen; i++)
+ pad |= p[i];
+ pad = pad != 0 ? 1 : 0;
+ }
/* reject illegal padding: first two octets MSB can't match */
if (pad && (neg == (p[1] & 0x80))) {
ASN1err(ASN1_F_C2I_IBUF, ASN1_R_ILLEGAL_PADDING);
More information about the openssl-commits
mailing list