From 8aeb9df0f54bd06a66bd3abb696ec058dc6a832a Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Thu, 12 Jan 2017 15:46:13 +0100 Subject: [PATCH] makecert: fix a regression with > 2048 bit When certificates with more than 2048 bits were generated and written to file the read function used a erroneous calculated length causing the used buffer to overflow. --- winpr/tools/makecert/makecert.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/winpr/tools/makecert/makecert.c b/winpr/tools/makecert/makecert.c index 282439a7b..075dbcbfb 100644 --- a/winpr/tools/makecert/makecert.c +++ b/winpr/tools/makecert/makecert.c @@ -1073,14 +1073,15 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv) break; } - length = new_len; x509_str = new_str; - status = BIO_read(bio, &x509_str[offset], length); + status = BIO_read(bio, &x509_str[offset], new_len); + if (status < 0) break; + length = length + new_len; offset += status; }