From 044da08973957b32703fe338eb95c5171ce471ba Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 7 Mar 2026 20:54:31 +0100 Subject: lib: Fix certificate DER encoding and key buffers i2d_X509() allocated buf->data via OPENSSL_malloc(), but callers free it with freebuf() which uses free(). Fix by allocating with malloc() and encoding directly into the buffer. Also replaces MSGBUFSZ with CRYPT_KEY_BUFSZ (4096) for key material buffers and removes leftover debug logging. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/protobuf.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/lib/protobuf.c') diff --git a/src/lib/protobuf.c b/src/lib/protobuf.c index 77f06032..28b3aab2 100644 --- a/src/lib/protobuf.c +++ b/src/lib/protobuf.c @@ -161,6 +161,8 @@ struct name_info name_info_msg_to_s(const name_info_msg_t * msg) assert(msg != NULL); assert(strlen(msg->name) <= NAME_SIZE); + memset(&s, 0, sizeof(s)); + strcpy(s.name, msg->name); strcpy(s.s.key, msg->skey); strcpy(s.s.crt, msg->scrt); -- cgit v1.2.3