Make sure OSSL_STORE_load() isn't caught in an endless loop
authorRichard Levitte <levitte@openssl.org>
Sat, 1 Jul 2017 16:25:43 +0000 (18:25 +0200)
committerRichard Levitte <levitte@openssl.org>
Mon, 3 Jul 2017 05:47:13 +0000 (07:47 +0200)
The post process callback might potentially say "no" to everything (by
constantly returning NULL) and thereby cause an endless loop.  Ensure
that we stop all processing when "eof" is reached.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/3823)

crypto/store/store_lib.c

index d5bb8b8..91faae2 100644 (file)
@@ -90,6 +90,9 @@ OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx)
     OSSL_STORE_INFO *v = NULL;
 
  again:
     OSSL_STORE_INFO *v = NULL;
 
  again:
+    if (OSSL_STORE_eof(ctx))
+        return NULL;
+
     v = ctx->loader->load(ctx->loader_ctx, ctx->ui_method, ctx->ui_data);
 
     if (ctx->post_process != NULL && v != NULL) {
     v = ctx->loader->load(ctx->loader_ctx, ctx->ui_method, ctx->ui_data);
 
     if (ctx->post_process != NULL && v != NULL) {