crypto/aes/asm/aesni-x86[_64].pl update, up to 14% improvement on
[openssl.git] / crypto / x509 / by_file.c
index 78b4c47751b12ed2918b440614a77cf225e8213c..57b08ee09458755db75bbc9c52459e79f11a9a21 100644 (file)
@@ -66,7 +66,7 @@
 #include <openssl/x509.h>
 #include <openssl/pem.h>
 
-#ifndef NO_STDIO
+#ifndef OPENSSL_NO_STDIO
 
 static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
        long argl, char **ret);
@@ -100,25 +100,27 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
        case X509_L_FILE_LOAD:
                if (argl == X509_FILETYPE_DEFAULT)
                        {
-                       ok=X509_load_cert_crl_file(ctx,X509_get_default_cert_file(),
-                               X509_FILETYPE_PEM);
+                       file = (char *)getenv(X509_get_default_cert_file_env());
+                       if (file)
+                               ok = (X509_load_cert_crl_file(ctx,file,
+                                             X509_FILETYPE_PEM) != 0);
+
+                       else
+                               ok = (X509_load_cert_crl_file(ctx,X509_get_default_cert_file(),
+                                             X509_FILETYPE_PEM) != 0);
+
                        if (!ok)
                                {
                                X509err(X509_F_BY_FILE_CTRL,X509_R_LOADING_DEFAULTS);
                                }
-                       else
-                               {
-                               file=(char *)Getenv(X509_get_default_cert_file_env());
-                               ok=X509_load_cert_crl_file(ctx,file,
-                                       X509_FILETYPE_PEM);
-                               }
                        }
                else
                        {
                        if(argl == X509_FILETYPE_PEM)
-                               ok=X509_load_cert_crl_file(ctx,argp,
-                                       X509_FILETYPE_PEM);
-                       else ok=X509_load_cert_file(ctx,argp,(int)argl);
+                               ok = (X509_load_cert_crl_file(ctx,argp,
+                                       X509_FILETYPE_PEM) != 0);
+                       else
+                               ok = (X509_load_cert_file(ctx,argp,(int)argl) != 0);
                        }
                break;
                }
@@ -148,7 +150,7 @@ int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)
                        x=PEM_read_bio_X509_AUX(in,NULL,NULL,NULL);
                        if (x == NULL)
                                {
-                               if ((ERR_GET_REASON(ERR_peek_error()) ==
+                               if ((ERR_GET_REASON(ERR_peek_last_error()) ==
                                        PEM_R_NO_START_LINE) && (count > 0))
                                        {
                                        ERR_clear_error();
@@ -215,7 +217,7 @@ int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type)
                        x=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);
                        if (x == NULL)
                                {
-                               if ((ERR_GET_REASON(ERR_peek_error()) ==
+                               if ((ERR_GET_REASON(ERR_peek_last_error()) ==
                                        PEM_R_NO_START_LINE) && (count > 0))
                                        {
                                        ERR_clear_error();
@@ -283,7 +285,8 @@ int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
                if(itmp->x509) {
                        X509_STORE_add_cert(ctx->store_ctx, itmp->x509);
                        count++;
-               } else if(itmp->crl) {
+               }
+               if(itmp->crl) {
                        X509_STORE_add_crl(ctx->store_ctx, itmp->crl);
                        count++;
                }
@@ -293,5 +296,5 @@ int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)
 }
 
 
-#endif /* NO_STDIO */
+#endif /* OPENSSL_NO_STDIO */