summaryrefslogtreecommitdiff
path: root/trust/asn1.c
diff options
context:
space:
mode:
Diffstat (limited to 'trust/asn1.c')
-rw-r--r--trust/asn1.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/trust/asn1.c b/trust/asn1.c
index fcd8e1c..653d816 100644
--- a/trust/asn1.c
+++ b/trust/asn1.c
@@ -197,7 +197,7 @@ p11_asn1_read (node_asn *asn,
const char *field,
size_t *length)
{
- void *value;
+ unsigned char *value;
int len;
int ret;
@@ -212,12 +212,15 @@ p11_asn1_read (node_asn *asn,
return_val_if_fail (ret == ASN1_MEM_ERROR, NULL);
- value = malloc (len);
+ value = malloc (len + 1);
return_val_if_fail (value != NULL, NULL);
ret = asn1_read_value (asn, field, value, &len);
return_val_if_fail (ret == ASN1_SUCCESS, NULL);
+ /* Courtesy zero terminated */
+ value[len] = '\0';
+
*length = len;
return value;
}