check return values
authorBodo Möller <bodo@openssl.org>
Wed, 17 Apr 2002 09:31:02 +0000 (09:31 +0000)
committerBodo Möller <bodo@openssl.org>
Wed, 17 Apr 2002 09:31:02 +0000 (09:31 +0000)
Submitted by: Nils Larsch

CHANGES
apps/req.c

diff --git a/CHANGES b/CHANGES
index 1e11b9a83e88ed8949b33e21a8d976bb8ddef368..858b257a9b9f586cdf3dcd0ae9e8ba6af4e3273d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1591,6 +1591,9 @@ des-cbc           3624.96k     5258.21k     5530.91k     5624.30k     5628.26k
 
  Changes between 0.9.6c and 0.9.6d  [XX xxx 2002]
 
+  *) Check various X509_...() return values in apps/req.c.
+     [Nils Larsch <nla@trustcenter.de>]
+
   *) Fix BASE64 decode (EVP_DecodeUpdate) for data with CR/LF ended lines:
      an end-of-file condition would erronously be flagged, when the CRLF
      was just at the end of a processed block. The bug was discovered when
index b986dae339b81a742c12a78e81bcc9e11f75edfe..3379cb206d869efdad4f308564a2b80eeae2fe3e 100644 (file)
@@ -306,7 +306,7 @@ int MAIN(int argc, char **argv)
                                                goto end;
                                                }
 
-                                       dtmp=X509_get_pubkey(xtmp);
+                                       if ((dtmp=X509_get_pubkey(xtmp)) == NULL) goto end;
                                        if (dtmp->type == EVP_PKEY_DSA)
                                                dsa_params=DSAparams_dup(dtmp->pkey.dsa);
                                        EVP_PKEY_free(dtmp);
@@ -818,19 +818,20 @@ loop:
                        /* Set version to V3 */
                        if(!X509_set_version(x509ss, 2)) goto end;
                        if (serial)
-                               X509_set_serialNumber(x509ss, serial);
+                               {
+                               if (!X509_set_serialNumber(x509ss, serial)) goto end;
+                               }
                        else
-                               ASN1_INTEGER_set(X509_get_serialNumber(x509ss),0L);
-
-                       X509_set_issuer_name(x509ss,
-                               X509_REQ_get_subject_name(req));
-                       X509_gmtime_adj(X509_get_notBefore(x509ss),0);
-                       X509_gmtime_adj(X509_get_notAfter(x509ss),
-                               (long)60*60*24*days);
-                       X509_set_subject_name(x509ss,
-                               X509_REQ_get_subject_name(req));
+                               {
+                               if (!ASN1_INTEGER_set(X509_get_serialNumber(x509ss),0L)) goto end;
+                               }
+
+                       if (!X509_set_issuer_name(x509ss, X509_REQ_get_subject_name(req))) goto end;
+                       if (!X509_gmtime_adj(X509_get_notBefore(x509ss),0)) goto end;
+                       if (!X509_gmtime_adj(X509_get_notAfter(x509ss), (long)60*60*24*days)) goto end;
+                       if (!X509_set_subject_name(x509ss, X509_REQ_get_subject_name(req))) goto end;
                        tmppkey = X509_REQ_get_pubkey(req);
-                       X509_set_pubkey(x509ss,tmppkey);
+                       if (!tmppkey || !X509_set_pubkey(x509ss,tmppkey)) goto end;
                        EVP_PKEY_free(tmppkey);
 
                        /* Set up V3 context struct */
@@ -1129,7 +1130,7 @@ static int make_REQ(X509_REQ *req, EVP_PKEY *pkey, char *subj, int attribs,
                }
        if(!i) goto err;
 
-       X509_REQ_set_pubkey(req,pkey);
+       if (!X509_REQ_set_pubkey(req,pkey)) goto err;
 
        ret=1;
 err: