Skip to content

Commit

Permalink
Fix ASAN issue in b64decode
Browse files Browse the repository at this point in the history
  • Loading branch information
capuanob authored and gittiver committed Jun 30, 2024
1 parent afad892 commit c63e977
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/crow/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c63e977

Please sign in to comment.