diff options
author | Stef Walter <stef@thewalter.net> | 2014-08-08 09:40:44 +0200 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2014-08-08 09:40:44 +0200 |
commit | 73362b5c853d3506a2eada353adfe4ebbe3fea92 (patch) | |
tree | 8df95f2cc54b300dd0b9f08dff02b1c8e7e4504d | |
parent | 428f419d5ab15741f51c1bb44fa684e0e6a139b6 (diff) | |
download | p11-kit-73362b5c853d3506a2eada353adfe4ebbe3fea92.tar.gz |
trust: Fix use of invalid memory in PEM parser
-rw-r--r-- | trust/pem.c | 4 |
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--- */ |