[openssl-commits] [openssl] master update

bernd.edlinger at hotmail.de bernd.edlinger at hotmail.de
Fri Nov 3 14:47:49 UTC 2017


The branch master has been updated
       via  7760384b403a61824c43cc767a11cd22abfa9e49 (commit)
       via  a6f622bc99ffdc7b34199babb9d200b24a7a6431 (commit)
       via  157997f0c00f63b6005f3b5b6e0bb659d795e136 (commit)
      from  ba24968dd1aad5fa389ac6f4c27389beaed5af5b (commit)


- Log -----------------------------------------------------------------
commit 7760384b403a61824c43cc767a11cd22abfa9e49
Author: Pavel Kopyl <p.kopyl at samsung.com>
Date:   Fri Oct 27 16:18:06 2017 +0300

    Check return value of OBJ_nid2obj in dsa_pub_encode.
    
    CLA: trivial
    
    Reviewed-by: Kurt Roeckx <kurt at roeckx.be>
    Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
    (Merged from https://github.com/openssl/openssl/pull/4600)

commit a6f622bc99ffdc7b34199babb9d200b24a7a6431
Author: Pavel Kopyl <p.kopyl at samsung.com>
Date:   Fri Oct 27 16:13:11 2017 +0300

    Add error handling in dsa_main and ASN1_i2d_bio.
    
    CLA: trivial
    
    Reviewed-by: Kurt Roeckx <kurt at roeckx.be>
    Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
    (Merged from https://github.com/openssl/openssl/pull/4600)

commit 157997f0c00f63b6005f3b5b6e0bb659d795e136
Author: Pavel Kopyl <p.kopyl at samsung.com>
Date:   Fri Oct 27 15:50:40 2017 +0300

    Fix error handling in i2d* functions.
    
    CLA: trivial
    
    Reviewed-by: Kurt Roeckx <kurt at roeckx.be>
    Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
    (Merged from https://github.com/openssl/openssl/pull/4600)

-----------------------------------------------------------------------

Summary of changes:
 apps/dsa.c             | 3 +++
 crypto/asn1/a_i2d_fp.c | 3 +++
 crypto/dsa/dsa_ameth.c | 8 ++++++--
 crypto/x509/x_pubkey.c | 8 ++++----
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/apps/dsa.c b/apps/dsa.c
index 5410f04..74a68ff 100644
--- a/apps/dsa.c
+++ b/apps/dsa.c
@@ -217,6 +217,9 @@ int dsa_main(int argc, char **argv)
     } else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) {
         EVP_PKEY *pk;
         pk = EVP_PKEY_new();
+        if (pk == NULL)
+           goto end;
+
         EVP_PKEY_set1_DSA(pk, dsa);
         if (outformat == FORMAT_PVK) {
             if (pubin) {
diff --git a/crypto/asn1/a_i2d_fp.c b/crypto/asn1/a_i2d_fp.c
index c3ed991..980c65a 100644
--- a/crypto/asn1/a_i2d_fp.c
+++ b/crypto/asn1/a_i2d_fp.c
@@ -38,6 +38,9 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
     int i, j = 0, n, ret = 1;
 
     n = i2d(x, NULL);
+    if (n <= 0)
+        return 0;
+
     b = OPENSSL_malloc(n);
     if (b == NULL) {
         ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c
index 8da047d..9c5b8aa 100644
--- a/crypto/dsa/dsa_ameth.c
+++ b/crypto/dsa/dsa_ameth.c
@@ -82,6 +82,7 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
     int penclen;
     ASN1_STRING *str = NULL;
     ASN1_INTEGER *pubint = NULL;
+    ASN1_OBJECT *aobj;
 
     dsa = pkey->pkey.dsa;
     if (pkey->save_parameters && dsa->p && dsa->q && dsa->g) {
@@ -114,8 +115,11 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
         goto err;
     }
 
-    if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_DSA),
-                               ptype, str, penc, penclen))
+    aobj = OBJ_nid2obj(EVP_PKEY_DSA);
+    if (aobj == NULL)
+        goto err;
+
+    if (X509_PUBKEY_set0_param(pk, aobj, ptype, str, penc, penclen))
         return 1;
 
  err:
diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c
index 76635b8..73977cd 100644
--- a/crypto/x509/x_pubkey.c
+++ b/crypto/x509/x_pubkey.c
@@ -206,7 +206,7 @@ int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)
     if (!a)
         return 0;
     if (!X509_PUBKEY_set(&xpk, a))
-        return 0;
+        return -1;
     ret = i2d_X509_PUBKEY(xpk, pp);
     X509_PUBKEY_free(xpk);
     return ret;
@@ -246,7 +246,7 @@ int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp)
     pktmp = EVP_PKEY_new();
     if (pktmp == NULL) {
         ASN1err(ASN1_F_I2D_RSA_PUBKEY, ERR_R_MALLOC_FAILURE);
-        return 0;
+        return -1;
     }
     EVP_PKEY_set1_RSA(pktmp, a);
     ret = i2d_PUBKEY(pktmp, pp);
@@ -286,7 +286,7 @@ int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp)
     pktmp = EVP_PKEY_new();
     if (pktmp == NULL) {
         ASN1err(ASN1_F_I2D_DSA_PUBKEY, ERR_R_MALLOC_FAILURE);
-        return 0;
+        return -1;
     }
     EVP_PKEY_set1_DSA(pktmp, a);
     ret = i2d_PUBKEY(pktmp, pp);
@@ -325,7 +325,7 @@ int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp)
         return 0;
     if ((pktmp = EVP_PKEY_new()) == NULL) {
         ASN1err(ASN1_F_I2D_EC_PUBKEY, ERR_R_MALLOC_FAILURE);
-        return 0;
+        return -1;
     }
     EVP_PKEY_set1_EC_KEY(pktmp, a);
     ret = i2d_PUBKEY(pktmp, pp);


More information about the openssl-commits mailing list