Skip to content

eBPF-based security platform

crypto: copy no subject out of an empty memory BIO

Daniel Borkmann74b27d2a8542
diff --git a/util/crypto_openssl.c b/util/crypto_openssl.c
index a7080a75..3f6b13f9 100644
--- a/util/crypto_openssl.c
+++ b/util/crypto_openssl.c
@@ -328,7 +328,8 @@ int cert_subject(const struct cert *cert, char *out, size_t out_sz)
ret = -ENAMETOOLONG;
if (len < 0 || (size_t)len >= out_sz)
goto out;
- memcpy(out, text, (size_t)len);
+ if (len)
+ memcpy(out, text, (size_t)len);
out[len] = '\0';
ret = 0;
out: