From 92523973caae8b195c4d39b6cf872ea09d72d497 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 8 Aug 2014 09:40:44 +0200 Subject: trust: Fix use of invalid memory in PEM parser --- trust/pem.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/trust/pem.c b/trust/pem.c index 7fe0076..ce4f554 100644 --- a/trust/pem.c +++ b/trust/pem.c @@ -85,10 +85,8 @@ pem_find_begin (const char *data, if (type) { pref += ARMOR_PREF_BEGIN_L; assert (suff > pref); - *type = malloc (suff - pref + 1); + *type = strndup (pref, suff - pref); return_val_if_fail (*type != NULL, NULL); - memcpy (*type, pref, suff - pref); - (*type)[suff - pref] = 0; } /* The byte after this ---BEGIN--- */ -- cgit v1.1