Do not NUL terminate base64 decoded output (#1752)

This is binary data and must use the explicit length.
This commit is contained in:
Andrew Gaul
2021-08-31 00:15:47 +09:00
committed by GitHub
parent dac6885fb0
commit cd98afdd7b
3 changed files with 31 additions and 8 deletions

View File

@ -438,7 +438,7 @@ unsigned char* s3fs_decode64(const char* input, size_t* plength)
if(!input || 0 == strlen(input) || !plength){
return NULL;
}
result = new unsigned char[strlen(input) / 4 * 3 + 1];
result = new unsigned char[strlen(input) / 4 * 3];
unsigned char parts[4];
size_t input_len = strlen(input);
@ -460,7 +460,6 @@ unsigned char* s3fs_decode64(const char* input, size_t* plength)
}
result[wpos++] = ((parts[2] << 6) & 0xc0) | (parts[3] & 0x3f);
}
result[wpos] = '\0';
*plength = wpos;
return result;
}