From 8684886cb1af16c18163bfb5ca254cdbbae7cd8d Mon Sep 17 00:00:00 2001 From: Bailey Capuano Date: Wed, 26 Jun 2024 19:12:53 -0600 Subject: [PATCH] Fix ASAN issue in b64decode --- include/crow/utility.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/crow/utility.h b/include/crow/utility.h index 8d72738ea..7be9a814c 100644 --- a/include/crow/utility.h +++ b/include/crow/utility.h @@ -640,9 +640,9 @@ namespace crow size = (size / 4 * 3) + 2; // Not subtracting extra characters because they're truncated in int division // Padded - else if (data[size - 2] == '=') // padded with '==' + else if (size >= 2 && data[size - 2] == '=') // padded with '==' size = (size / 4 * 3) - 2; // == padding means the last block only has 1 character instead of 3, hence the '-2' - else if (data[size - 1] == '=') // padded with '=' + else if (size >= 1 && data[size - 1] == '=') // padded with '=' size = (size / 4 * 3) - 1; // = padding means the last block only has 2 character instead of 3, hence the '-1' // Padding not needed