From c3f6b665cc0698ec96cc13b419ca5e3cdbabced4 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 14 Apr 2023 14:21:22 +0200 Subject: [PATCH] [server,proxy] improve error message for invalid base64 If the certificate or private key are supplied as base64 encoded string inform what happened before aborting. --- server/proxy/pf_config.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/proxy/pf_config.c b/server/proxy/pf_config.c index d772854e4..3f3fc0f3e 100644 --- a/server/proxy/pf_config.c +++ b/server/proxy/pf_config.c @@ -393,7 +393,10 @@ static char* pf_config_decode_base64(const char* data, const char* name, size_t* size_t decoded_length = 0; char* decoded = NULL; if (!data) + { + WLog_ERR(TAG, "Invalid base64 data [%p] for %s", data, name); return NULL; + } WINPR_ASSERT(name); WINPR_ASSERT(pLength); @@ -401,7 +404,11 @@ static char* pf_config_decode_base64(const char* data, const char* name, size_t* const size_t length = strlen(data); crypto_base64_decode(data, length, (BYTE**)&decoded, &decoded_length); if (!decoded || decoded_length == 0) - WLog_ERR(TAG, "Failed to decode base64 data from %s of length %" PRIuz, name, length); + { + WLog_ERR(TAG, "Failed to decode base64 data of length %" PRIuz " for %s", length, name); + free(decoded); + return NULL; + } WINPR_ASSERT(strnlen(decoded, decoded_length) == decoded_length - 1); *pLength = decoded_length; return decoded;