summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiod <>2014-07-09 09:07:00 +0000
committermiod <>2014-07-09 09:07:00 +0000
commit93c72cf9da4c9d69f62ff20c6d3581aae665cb45 (patch)
treece4c9fb60aae0c926cd43f11c241226fe69e5367
parentea9e0aeb7bfbb0e9071d08a944d7c7978d8a39d7 (diff)
downloadopenbsd-93c72cf9da4c9d69f62ff20c6d3581aae665cb45.tar.gz
openbsd-93c72cf9da4c9d69f62ff20c6d3581aae665cb45.tar.bz2
openbsd-93c72cf9da4c9d69f62ff20c6d3581aae665cb45.zip
Be more strict in RSA_padding_check_X931(), and thus avoid a possible
memcpy() with a negative size. ok tedu@
-rw-r--r--src/lib/libcrypto/rsa/rsa_x931.c4
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa_x931.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_x931.c b/src/lib/libcrypto/rsa/rsa_x931.c
index f22c50ba13..c3305139f8 100644
--- a/src/lib/libcrypto/rsa/rsa_x931.c
+++ b/src/lib/libcrypto/rsa/rsa_x931.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_x931.c,v 1.3 2014/07/09 08:20:08 miod Exp $ */ 1/* $OpenBSD: rsa_x931.c,v 1.4 2014/07/09 09:07:00 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2005. 3 * project 2005.
4 */ 4 */
@@ -135,7 +135,7 @@ RSA_padding_check_X931(unsigned char *to, int tlen, const unsigned char *from,
135 } else 135 } else
136 j = flen - 2; 136 j = flen - 2;
137 137
138 if (p[j] != 0xCC) { 138 if (j < 0 || p[j] != 0xCC) {
139 RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_TRAILER); 139 RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_TRAILER);
140 return -1; 140 return -1;
141 } 141 }
diff --git a/src/lib/libssl/src/crypto/rsa/rsa_x931.c b/src/lib/libssl/src/crypto/rsa/rsa_x931.c
index f22c50ba13..c3305139f8 100644
--- a/src/lib/libssl/src/crypto/rsa/rsa_x931.c
+++ b/src/lib/libssl/src/crypto/rsa/rsa_x931.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_x931.c,v 1.3 2014/07/09 08:20:08 miod Exp $ */ 1/* $OpenBSD: rsa_x931.c,v 1.4 2014/07/09 09:07:00 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2005. 3 * project 2005.
4 */ 4 */
@@ -135,7 +135,7 @@ RSA_padding_check_X931(unsigned char *to, int tlen, const unsigned char *from,
135 } else 135 } else
136 j = flen - 2; 136 j = flen - 2;
137 137
138 if (p[j] != 0xCC) { 138 if (j < 0 || p[j] != 0xCC) {
139 RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_TRAILER); 139 RSAerr(RSA_F_RSA_PADDING_CHECK_X931, RSA_R_INVALID_TRAILER);
140 return -1; 140 return -1;
141 } 141 }