summaryrefslogtreecommitdiffstats
path: root/apps/cmp.c
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-09-07 19:39:52 +0200
committerPauli <paul.dale@oracle.com>2020-09-11 08:06:47 +1000
commitb0a4cbead384e2ac8dbb697795ace242e1b07c18 (patch)
tree24d186c1549574c43a160ceb21b139c0f0ce6710 /apps/cmp.c
parentd3dbc9b50043fd1b4464b3f2b0ab8c54075099d6 (diff)
apps/cmp.c: Improve safeguard assertion on consistency of cmp_options[] and cmp_vars[]
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12836)
Diffstat (limited to 'apps/cmp.c')
-rw-r--r--apps/cmp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/apps/cmp.c b/apps/cmp.c
index ce2513bd0d..003c75517d 100644
--- a/apps/cmp.c
+++ b/apps/cmp.c
@@ -2153,8 +2153,17 @@ static int read_config(void)
* would not make sense within the config file.
* Moreover, these two options and OPT_VERBOSITY have already been handled.
*/
+ int n_options = OSSL_NELEM(cmp_options) - 1;
for (i = start - OPT_HELP, opt = &cmp_options[start];
+ opt->name; i++, opt++)
+ if (!strcmp(opt->name, OPT_SECTION_STR)
+ || !strcmp(opt->name, OPT_MORE_STR))
+ n_options--;
+ OPENSSL_assert(OSSL_NELEM(cmp_vars) == n_options
+ + OPT_PROV__FIRST + 1 - OPT_PROV__LAST
+ + OPT_V__FIRST + 1 - OPT_V__LAST);
+ for (i = start - OPT_HELP, opt = &cmp_options[start];
opt->name; i++, opt++) {
if (!strcmp(opt->name, OPT_SECTION_STR)
|| !strcmp(opt->name, OPT_MORE_STR)) {
@@ -2167,10 +2176,6 @@ static int read_config(void)
&& opt->retval < OPT_V__LAST);
if (provider_option || verification_option)
i--;
- if (cmp_vars[i].txt == NULL) {
- CMP_err1("internal: cmp_vars array too short, i=%d", i);
- return 0;
- }
switch (opt->valtype) {
case '-':
case 'n':