Typos.
[openssl.git] / crypto / ocsp / ocsp_vfy.c
index be399a3a3597abe873da499da1d6bb461391deb1..3d58dfb06cf34ff940a492c97556271b9cecf5e8 100644 (file)
@@ -3,7 +3,7 @@
  * project 2000.
  */
 /* ====================================================================
- * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 2000-2004 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -101,10 +101,16 @@ int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
                }
        if (!(flags & OCSP_NOVERIFY))
                {
+               int init_res;
                if(flags & OCSP_NOCHAIN)
-                       X509_STORE_CTX_init(&ctx, st, signer, NULL);
+                       init_res = X509_STORE_CTX_init(&ctx, st, signer, NULL);
                else
-                       X509_STORE_CTX_init(&ctx, st, signer, bs->certs);
+                       init_res = X509_STORE_CTX_init(&ctx, st, signer, bs->certs);
+               if(!init_res)
+                       {
+                       OCSPerr(OCSP_F_OCSP_BASIC_VERIFY,ERR_R_X509_LIB);
+                       goto end;
+                       }
 
                X509_STORE_CTX_set_purpose(&ctx, X509_PURPOSE_OCSP_HELPER);
                ret = X509_verify_cert(&ctx);
@@ -266,7 +272,7 @@ static int ocsp_check_ids(STACK_OF(OCSP_SINGLERESP) *sresp, OCSP_CERTID **ret)
 
        for (i = 1; i < idcount; i++)
                {
-               tmpid = sk_OCSP_SINGLERESP_value(sresp, 0)->certId;
+               tmpid = sk_OCSP_SINGLERESP_value(sresp, i)->certId;
                /* Check to see if IDs match */
                if (OCSP_id_issuer_cmp(cid, tmpid))
                        {
@@ -305,7 +311,7 @@ static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid,
                if ((cid->issuerNameHash->length != mdlen) ||
                   (cid->issuerKeyHash->length != mdlen))
                        return 0;
-               iname = X509_get_issuer_name(cert);
+               iname = X509_get_subject_name(cert);
                if (!X509_NAME_digest(iname, dgst, md, NULL))
                        return -1;
                if (memcmp(md, cid->issuerNameHash->data, mdlen))
@@ -324,7 +330,7 @@ static int ocsp_match_issuerid(X509 *cert, OCSP_CERTID *cid,
                OCSP_CERTID *tmpid;
                for (i = 0; i < sk_OCSP_SINGLERESP_num(sresp); i++)
                        {
-                       tmpid = sk_OCSP_SINGLERESP_value(sresp, 0)->certId;
+                       tmpid = sk_OCSP_SINGLERESP_value(sresp, i)->certId;
                        ret = ocsp_match_issuerid(cert, tmpid, NULL);
                        if (ret <= 0) return ret;
                        }
@@ -389,10 +395,17 @@ int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, X509_STORE *st
                }
        if (!(flags & OCSP_NOVERIFY))
                {
+               int init_res;
                if(flags & OCSP_NOCHAIN)
-                       X509_STORE_CTX_init(&ctx, store, signer, NULL);
+                       init_res = X509_STORE_CTX_init(&ctx, store, signer, NULL);
                else
-                       X509_STORE_CTX_init(&ctx, store, signer, req->optionalSignature->certs);
+                       init_res = X509_STORE_CTX_init(&ctx, store, signer,
+                                       req->optionalSignature->certs);
+               if(!init_res)
+                       {
+                       OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY,ERR_R_X509_LIB);
+                       return 0;
+                       }
 
                X509_STORE_CTX_set_purpose(&ctx, X509_PURPOSE_OCSP_HELPER);
                X509_STORE_CTX_set_trust(&ctx, X509_TRUST_OCSP_REQUEST);