evp: fix coverity 1473381 - dereference after null check
authorPauli <ppzgs1@gmail.com>
Wed, 17 Mar 2021 03:35:59 +0000 (13:35 +1000)
committerPauli <ppzgs1@gmail.com>
Sat, 20 Mar 2021 00:18:32 +0000 (10:18 +1000)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14589)

crypto/evp/ctrl_params_translate.c

index 32af4eedd3651ac2aef0b32562a3e051324cce61..808804ab3a959d06ed0f474a401c759619283ac1 100644 (file)
@@ -1512,8 +1512,14 @@ static int get_payload_group_name(enum state state,
         return 0;
     }
 
-    if (ctx->p2 != NULL)
-        ctx->p1 = strlen(ctx->p2);
+    /*
+     * Quietly ignoring unknown groups matches the behaviour on the provider
+     * side.
+     */
+    if (ctx->p2 == NULL)
+        return 1;
+
+    ctx->p1 = strlen(ctx->p2);
     return default_fixup_args(state, translation, ctx);
 }