From b91e928286983b61a111a1f4fadbcc9e74fed575 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Fri, 9 Jul 2021 21:59:27 -0700 Subject: [PATCH] :racehorse: max base64 header size calculated compile time based on max name --- src/user_filter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/user_filter.cpp b/src/user_filter.cpp index 25e834c..d40789c 100644 --- a/src/user_filter.cpp +++ b/src/user_filter.cpp @@ -9,13 +9,13 @@ void UserFilter::doFilter(const HttpRequestPtr &re FilterChainCallback &&fccb) { std::string_view auth_header = req->getHeader("Authorization"); - if (auth_header.size() > 6 && auth_header.size() <= 688) //"Basic " + (username + ':' + password) * 4/3 + if (auth_header.size() > 6 && auth_header.size() <= ((max_name_size + 256) * 4) / 3) //"Basic " + (username + ':' + password) * 4/3 { if (auth_header.substr(0, 6) == "Basic ") { std::string_view base64_input = auth_header.substr(6); - static thread_local char result_buffer[511]; //(255 username + ':' + 255 password) - std::memset(result_buffer, 0, 511); + static thread_local char result_buffer[max_name_size + 256]; //(username + ':' + 255 password) + std::memset(result_buffer, 0, max_name_size + 256); size_t new_sz; base64_decode(base64_input.data(), base64_input.size(), result_buffer, &new_sz, 0);