summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2021-09-17 16:37:24 -0400
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2021-09-17 16:37:24 -0400
commita00a79ddf41eb14d56bdea076b5c252029896431 (patch)
tree7cdd548dccb4c3adc877e8b404e2fd8a6b9c684f
parent78449e86c22dbad71c634cb18fb264a37d479e32 (diff)
downloadgnutls-a00a79ddf41eb14d56bdea076b5c252029896431.tar.gz
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 <dkg@fifthhorseman.net>
-rw-r--r--lib/x509/common.c3
1 files changed, 2 insertions, 1 deletions
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)