]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
APPS/cmp.c: Move warning on overlong section name to make it effective again
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Sat, 11 Sep 2021 21:08:13 +0000 (23:08 +0200)
committerDr. David von Oheimb <dev@ddvo.net>
Fri, 17 Sep 2021 08:02:52 +0000 (10:02 +0200)
Fixes #16585

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16586)

apps/cmp.c

index 74c8cd71f1a8f5e5bcd0311ee48515d011adf7bf..170ac816f2a55d1c25887aad0022ca759a8655d4 100644 (file)
@@ -2001,14 +2001,14 @@ static const char *prev_item(const char *opt, const char *end)
     while (beg != opt && beg[-1] != ',' && !isspace(beg[-1]))
         beg--;
     len = end - beg;
-    if (len > SECTION_NAME_MAX)
+    if (len > SECTION_NAME_MAX) {
+        CMP_warn2("using only first %d characters of section name starting with \"%s\"",
+                  SECTION_NAME_MAX, opt_item);
         len = SECTION_NAME_MAX;
+    }
     strncpy(opt_item, beg, len);
     opt_item[SECTION_NAME_MAX] = '\0'; /* avoid gcc v8 O3 stringop-truncation */
     opt_item[len] = '\0';
-    if (len > SECTION_NAME_MAX)
-        CMP_warn2("using only first %d characters of section name starting with \"%s\"",
-                  SECTION_NAME_MAX, opt_item);
     while (beg != opt && (beg[-1] == ',' || isspace(beg[-1])))
         beg--;
     return beg;