[openssl] openssl-3.0 update
tomas at openssl.org
tomas at openssl.org
Mon Oct 25 13:02:10 UTC 2021
The branch openssl-3.0 has been updated
via e07db550547636881c38a4834cca2f9a8689d60c (commit)
from 1461059fe97b9abfb1c5414b314790f0bd65e0a0 (commit)
- Log -----------------------------------------------------------------
commit e07db550547636881c38a4834cca2f9a8689d60c
Author: Tomas Mraz <tomas at openssl.org>
Date: Wed Oct 13 09:00:31 2021 +0200
cmp.c: Avoid dereference with negative index and use memcpy
This prevents a compile-time warning on newer gcc.
Also fix the related warning message.
Fixes #16814
Reviewed-by: Shane Lontis <shane.lontis at oracle.com>
Reviewed-by: Paul Dale <pauli at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16821)
(cherry picked from commit 767db672c429aeb98a68b0e310dea15f1b48eb84)
-----------------------------------------------------------------------
Summary of changes:
apps/cmp.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/apps/cmp.c b/apps/cmp.c
index 170ac816f2..b6e88e64f6 100644
--- a/apps/cmp.c
+++ b/apps/cmp.c
@@ -1989,7 +1989,7 @@ static void print_itavs(STACK_OF(OSSL_CMP_ITAV) *itavs)
}
static char opt_item[SECTION_NAME_MAX + 1];
-/* get previous name from a comma-separated list of names */
+/* get previous name from a comma or space-separated list of names */
static const char *prev_item(const char *opt, const char *end)
{
const char *beg;
@@ -1998,19 +1998,28 @@ static const char *prev_item(const char *opt, const char *end)
if (end == opt)
return NULL;
beg = end;
- while (beg != opt && beg[-1] != ',' && !isspace(beg[-1]))
- beg--;
+ while (beg > opt) {
+ --beg;
+ if (beg[0] == ',' || isspace(beg[0])) {
+ ++beg;
+ break;
+ }
+ }
len = end - beg;
if (len > SECTION_NAME_MAX) {
- CMP_warn2("using only first %d characters of section name starting with \"%s\"",
- SECTION_NAME_MAX, opt_item);
+ CMP_warn3("using only first %d characters of section name starting with \"%.*s\"",
+ SECTION_NAME_MAX, SECTION_NAME_MAX, beg);
len = SECTION_NAME_MAX;
}
- strncpy(opt_item, beg, len);
- opt_item[SECTION_NAME_MAX] = '\0'; /* avoid gcc v8 O3 stringop-truncation */
+ memcpy(opt_item, beg, len);
opt_item[len] = '\0';
- while (beg != opt && (beg[-1] == ',' || isspace(beg[-1])))
- beg--;
+ while (beg > opt) {
+ --beg;
+ if (beg[0] != ',' && !isspace(beg[0])) {
+ ++beg;
+ break;
+ }
+ }
return beg;
}
More information about the openssl-commits
mailing list