changeset 26342:114f0d8bf0d9

lib-dcrypt: Fix i2d_ASN1_OBJECT usage i2d_ASN1_OBJECT tells how much memory we need.
author Aki Tuomi <aki.tuomi@open-xchange.com>
date Fri, 23 Aug 2019 19:39:16 +0300
parents 671182f4a7f0
children af4b3417150f
files src/lib-dcrypt/dcrypt-openssl.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dcrypt/dcrypt-openssl.c	Fri Aug 23 13:48:03 2019 +0300
+++ b/src/lib-dcrypt/dcrypt-openssl.c	Fri Aug 23 19:39:16 2019 +0300
@@ -2282,14 +2282,15 @@
 	if (obj == NULL)
 		return dcrypt_openssl_error(error_r);
 
-	size_t len =  OBJ_length(obj);
+	size_t len = OBJ_length(obj);
 	if (len == 0)
 	{
 		if (error_r != NULL)
 			*error_r = "Object has no OID assigned";
 		return FALSE;
 	}
-	unsigned char *bufptr = buffer_append_space_unsafe(oid, len + 2);
+	len = i2d_ASN1_OBJECT(obj, NULL);
+	unsigned char *bufptr = buffer_append_space_unsafe(oid, len);
 	i2d_ASN1_OBJECT(obj, &bufptr);
 	ASN1_OBJECT_free(obj);
 	if (bufptr != NULL) {