]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix OSSL_PARAM_allocate_from_text() for OSSL_PARAM_UTF8_STRING
authorRichard Levitte <levitte@openssl.org>
Tue, 23 Feb 2021 07:10:02 +0000 (08:10 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 24 Feb 2021 18:50:10 +0000 (19:50 +0100)
OSSL_PARAM_allocate_from_text() was still setting the length in bytes
of the UTF8 string to include the terminating NUL byte, while recent
changes excludes that byte from the length.

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

crypto/params_from_text.c

index b019744f9b71afec614cb9af46a3c00c95c7f628..3ff94c7475f7c7d508b310e6fb9bae2515dc1ae5 100644 (file)
@@ -151,6 +151,8 @@ static int construct_from_text(OSSL_PARAM *to, const OSSL_PARAM *paramdef,
 #else
             strncpy(buf, value, buf_n);
 #endif
+            /* Don't count the terminating NUL byte as data */
+            buf_n--;
             break;
         case OSSL_PARAM_OCTET_STRING:
             if (ishex) {