summaryrefslogtreecommitdiff
path: root/trust
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2014-08-08 09:40:44 +0200
committerStef Walter <stef@thewalter.net>2014-08-08 09:59:20 +0200
commit92523973caae8b195c4d39b6cf872ea09d72d497 (patch)
treeee110f0d1dfbb93f82ac70733ed7d539549a9f85 /trust
parentc22e37091278ffb339c692f5c994c3393b12a254 (diff)
trust: Fix use of invalid memory in PEM parser
Diffstat (limited to 'trust')
-rw-r--r--trust/pem.c4
1 files changed, 1 insertions, 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--- */