Address some code-analysis issues.
[openssl.git] / crypto / store / loader_file.c
index 99c9350cf80399b94058bc95c6855b39c364c79d..588a5816321f5a776cf245fe53b406b4c2784dcf 100644 (file)
@@ -7,6 +7,7 @@
  * https://www.openssl.org/source/license.html
  */
 
+#include "e_os.h"
 #include <string.h>
 #include <sys/stat.h>
 #include <assert.h>
 #include <openssl/ui.h>
 #include <openssl/x509.h>        /* For the PKCS8 stuff o.O */
 #include "internal/asn1_int.h"
+#include "internal/ctype.h"
 #include "internal/o_dir.h"
 #include "internal/cryptlib.h"
 #include "internal/store_int.h"
 #include "store_locl.h"
 
-#include "e_os.h"
-
 #ifdef _WIN32
 # define stat    _stat
 #endif
@@ -783,7 +783,7 @@ static OSSL_STORE_LOADER_CTX *file_open(const OSSL_STORE_LOADER *loader,
 #ifdef _WIN32
         /* Windows file: URIs with a drive letter start with a / */
         if (p[0] == '/' && p[2] == ':' && p[3] == '/') {
-            char c = tolower(p[1]);
+            char c = ossl_tolower(p[1]);
 
             if (c >= 'a' && c <= 'z') {
                 p++;
@@ -855,7 +855,7 @@ static OSSL_STORE_LOADER_CTX *file_open(const OSSL_STORE_LOADER *loader,
         }
     } else {
         BIO *buff = NULL;
-        char peekbuf[4096];
+        char peekbuf[4096] = { 0, };
 
         if ((buff = BIO_new(BIO_f_buffer())) == NULL
             || (ctx->_.file.file = BIO_new_file(path, "rb")) == NULL) {
@@ -962,8 +962,8 @@ static OSSL_STORE_INFO *file_load_try_decode(OSSL_STORE_LOADER_CTX *ctx,
                                     ui_method, ui_data);
 
             if (try_matchcount > 0) {
-                if (matching_handlers)
-                    matching_handlers[*matchcount] = handler;
+
+                matching_handlers[*matchcount] = handler;
 
                 if (handler_ctx)
                     handler->destroy_ctx(&handler_ctx);