From: Daniel Kahn Gillmor Date: Fri, 17 Sep 2021 20:37:24 +0000 (-0400) Subject: lib/x509: Avoid memcpy when string is empty X-Git-Tag: 3.7.3~37^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a00a79ddf41eb14d56bdea076b5c252029896431;p=thirdparty%2Fgnutls.git lib/x509: Avoid memcpy when string is empty This fixes an ASAN warning in fuzz/gnutls_private_key_parser_fuzzer when run against the malformed private key fuzz/gnutls_private_key_parser_fuzzer.in/10a5c92fa30ddb6cbb4286d7699b2b7a7e032b17 Signed-off-by: Daniel Kahn Gillmor --- diff --git a/lib/x509/common.c b/lib/x509/common.c index c156bd96a9..94d206ff75 100644 --- a/lib/x509/common.c +++ b/lib/x509/common.c @@ -630,7 +630,8 @@ _gnutls_x509_decode_string(unsigned int etype, if (td.data == NULL) return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR); - memcpy(td.data, str, str_size); + if (str_size > 0) + memcpy(td.data, str, str_size); td.data[str_size] = 0; if (allow_ber)