openssl cms: avoid NULL derefs on option parsing
authortb <tb@openbsd.org>
Wed, 23 Mar 2022 15:16:59 +0000 (15:16 +0000)
committertb <tb@openbsd.org>
Wed, 23 Mar 2022 15:16:59 +0000 (15:16 +0000)
Two missing initializations in the new option handling cause a
segfault when -nodetach or -noindef is passed to openssl cms.

ok inoguchi jsing miod

usr.bin/openssl/cms.c

index 5b87694..a3004e8 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: cms.c,v 1.29 2022/01/16 07:11:49 inoguchi Exp $ */
+/* $OpenBSD: cms.c,v 1.30 2022/03/23 15:16:59 tb Exp $ */
 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project.
  */
@@ -769,12 +769,14 @@ static const struct option cms_options[] = {
                .name = "nodetach",
                .desc = "Use opaque signing",
                .type = OPTION_VALUE_AND,
+               .opt.value = &cms_config.flags,
                .value = ~CMS_DETACHED,
        },
        {
                .name = "noindef",
                .desc = "Disable CMS streaming",
                .type = OPTION_VALUE_AND,
+               .opt.value = &cms_config.flags,
                .value = ~CMS_STREAM,
        },
        {