diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/pem/pvkfmt.c | 10 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/pem/pvkfmt.c | 10 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/libcrypto/pem/pvkfmt.c b/src/lib/libcrypto/pem/pvkfmt.c index f5a9de39fc..c3fd0e8d0a 100644 --- a/src/lib/libcrypto/pem/pvkfmt.c +++ b/src/lib/libcrypto/pem/pvkfmt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: pvkfmt.c,v 1.14 2015/09/10 15:56:25 jsing Exp $ */ | 1 | /* $OpenBSD: pvkfmt.c,v 1.15 2016/03/02 05:02:35 beck 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 | */ |
| @@ -681,6 +681,10 @@ do_PVK_header(const unsigned char **in, unsigned int length, int skip_magic, | |||
| 681 | is_encrypted = read_ledword(&p); | 681 | is_encrypted = read_ledword(&p); |
| 682 | *psaltlen = read_ledword(&p); | 682 | *psaltlen = read_ledword(&p); |
| 683 | *pkeylen = read_ledword(&p); | 683 | *pkeylen = read_ledword(&p); |
| 684 | if (*psaltlen > 65536 || *pkeylen > 65536) { | ||
| 685 | PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_ERROR_CONVERTING_PRIVATE_KEY); | ||
| 686 | return 0; | ||
| 687 | } | ||
| 684 | 688 | ||
| 685 | if (is_encrypted && !*psaltlen) { | 689 | if (is_encrypted && !*psaltlen) { |
| 686 | PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_INCONSISTENT_HEADER); | 690 | PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_INCONSISTENT_HEADER); |
| @@ -796,7 +800,7 @@ b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u) | |||
| 796 | { | 800 | { |
| 797 | unsigned char pvk_hdr[24], *buf = NULL; | 801 | unsigned char pvk_hdr[24], *buf = NULL; |
| 798 | const unsigned char *p; | 802 | const unsigned char *p; |
| 799 | int buflen; | 803 | size_t buflen; |
| 800 | EVP_PKEY *ret = NULL; | 804 | EVP_PKEY *ret = NULL; |
| 801 | unsigned int saltlen, keylen; | 805 | unsigned int saltlen, keylen; |
| 802 | 806 | ||
| @@ -808,7 +812,7 @@ b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u) | |||
| 808 | 812 | ||
| 809 | if (!do_PVK_header(&p, 24, 0, &saltlen, &keylen)) | 813 | if (!do_PVK_header(&p, 24, 0, &saltlen, &keylen)) |
| 810 | return 0; | 814 | return 0; |
| 811 | buflen = (int) keylen + saltlen; | 815 | buflen = keylen + saltlen; |
| 812 | buf = malloc(buflen); | 816 | buf = malloc(buflen); |
| 813 | if (!buf) { | 817 | if (!buf) { |
| 814 | PEMerr(PEM_F_B2I_PVK_BIO, ERR_R_MALLOC_FAILURE); | 818 | PEMerr(PEM_F_B2I_PVK_BIO, ERR_R_MALLOC_FAILURE); |
diff --git a/src/lib/libssl/src/crypto/pem/pvkfmt.c b/src/lib/libssl/src/crypto/pem/pvkfmt.c index f5a9de39fc..c3fd0e8d0a 100644 --- a/src/lib/libssl/src/crypto/pem/pvkfmt.c +++ b/src/lib/libssl/src/crypto/pem/pvkfmt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: pvkfmt.c,v 1.14 2015/09/10 15:56:25 jsing Exp $ */ | 1 | /* $OpenBSD: pvkfmt.c,v 1.15 2016/03/02 05:02:35 beck 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 | */ |
| @@ -681,6 +681,10 @@ do_PVK_header(const unsigned char **in, unsigned int length, int skip_magic, | |||
| 681 | is_encrypted = read_ledword(&p); | 681 | is_encrypted = read_ledword(&p); |
| 682 | *psaltlen = read_ledword(&p); | 682 | *psaltlen = read_ledword(&p); |
| 683 | *pkeylen = read_ledword(&p); | 683 | *pkeylen = read_ledword(&p); |
| 684 | if (*psaltlen > 65536 || *pkeylen > 65536) { | ||
| 685 | PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_ERROR_CONVERTING_PRIVATE_KEY); | ||
| 686 | return 0; | ||
| 687 | } | ||
| 684 | 688 | ||
| 685 | if (is_encrypted && !*psaltlen) { | 689 | if (is_encrypted && !*psaltlen) { |
| 686 | PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_INCONSISTENT_HEADER); | 690 | PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_INCONSISTENT_HEADER); |
| @@ -796,7 +800,7 @@ b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u) | |||
| 796 | { | 800 | { |
| 797 | unsigned char pvk_hdr[24], *buf = NULL; | 801 | unsigned char pvk_hdr[24], *buf = NULL; |
| 798 | const unsigned char *p; | 802 | const unsigned char *p; |
| 799 | int buflen; | 803 | size_t buflen; |
| 800 | EVP_PKEY *ret = NULL; | 804 | EVP_PKEY *ret = NULL; |
| 801 | unsigned int saltlen, keylen; | 805 | unsigned int saltlen, keylen; |
| 802 | 806 | ||
| @@ -808,7 +812,7 @@ b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u) | |||
| 808 | 812 | ||
| 809 | if (!do_PVK_header(&p, 24, 0, &saltlen, &keylen)) | 813 | if (!do_PVK_header(&p, 24, 0, &saltlen, &keylen)) |
| 810 | return 0; | 814 | return 0; |
| 811 | buflen = (int) keylen + saltlen; | 815 | buflen = keylen + saltlen; |
| 812 | buf = malloc(buflen); | 816 | buf = malloc(buflen); |
| 813 | if (!buf) { | 817 | if (!buf) { |
| 814 | PEMerr(PEM_F_B2I_PVK_BIO, ERR_R_MALLOC_FAILURE); | 818 | PEMerr(PEM_F_B2I_PVK_BIO, ERR_R_MALLOC_FAILURE); |
