White space handling
@@ -118,11 +118,11 @@ int bscrypt_base64_decode(char *target, char *encoded, int base64_len) {
target = encoded;
int written = 0;
char tmp1, tmp2, tmp3, tmp4;
- while (base64_len >= 4) {
while (*encoded == '\r' || *encoded == '\n' || *encoded == ' ') {
base64_len--;
encoded++;
}
+ while (base64_len >= 4) {
tmp1 = *(encoded++);
tmp2 = *(encoded++);
tmp3 = *(encoded++);
@@ -137,6 +137,12 @@ int bscrypt_base64_decode(char *target, char *encoded, int base64_len) {
base64_len -= 4;
// count written bytes
written += 3;
+ // skip white space
+ while (base64_len &&
+ (*encoded == '\r' || *encoded == '\n' || *encoded == ' ')) {
+ base64_len--;
+ encoded++;
+ }
}
// deal with the "tail" of the mis-encoded stream - this shouldn't happen
tmp1 = 0;
