From 7f5675c8e5a1131b7ac12c0724c374f4def9a0f7 Mon Sep 17 00:00:00 2001 From: Andreas Steffen Date: Sun, 7 Oct 2012 17:07:35 +0200 Subject: [PATCH] check length of hex-encoded IV --- src/libstrongswan/plugins/pem/pem_builder.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libstrongswan/plugins/pem/pem_builder.c b/src/libstrongswan/plugins/pem/pem_builder.c index 9b9777031..eefb2eb48 100644 --- a/src/libstrongswan/plugins/pem/pem_builder.c +++ b/src/libstrongswan/plugins/pem/pem_builder.c @@ -288,8 +288,11 @@ static status_t pem_to_bin(chunk_t *blob, bool *pgp) " not supported", (int)dek.len, dek.ptr); return NOT_SUPPORTED; } - eat_whitespace(&value); - iv = chunk_from_hex(value, iv.ptr); + if (!eat_whitespace(&value) || value.len > 2*sizeof(iv_buf)) + { + return PARSE_ERROR; + } + iv = chunk_from_hex(value, iv_buf); } } else /* state is PEM_BODY */