Do not NUL terminate base64 decoded output (#1752)
This is binary data and must use the explicit length.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user