From 39d9123891845f203465dfda181f5c24b45756d1 Mon Sep 17 00:00:00 2001 From: kinichiro Date: Thu, 5 Dec 2019 20:00:50 +0900 Subject: [PATCH] Return 1 when openssl req -addext kv is duplicated CLA: trivial Fixes #10273 Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/10578) (cherry picked from commit 1aeec3dbc2d62f902698b1eba9ed31cbd436f9dc) --- apps/req.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/req.c b/apps/req.c index d717c493e5..a603907cd5 100644 --- a/apps/req.c +++ b/apps/req.c @@ -200,9 +200,12 @@ static int duplicated(LHASH_OF(OPENSSL_STRING) *addexts, char *kv) *p = '\0'; /* Finally have a clean "key"; see if it's there [by attempt to add it]. */ - if ((p = (char *)lh_OPENSSL_STRING_insert(addexts, (OPENSSL_STRING*)kv)) - != NULL || lh_OPENSSL_STRING_error(addexts)) { - OPENSSL_free(p != NULL ? p : kv); + p = (char *)lh_OPENSSL_STRING_insert(addexts, (OPENSSL_STRING*)kv); + if (p != NULL) { + OPENSSL_free(p); + return 1; + } else if (lh_OPENSSL_STRING_error(addexts)) { + OPENSSL_free(kv); return -1; } -- 2.25.1