mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-23 13:58:24 +00:00
Don't over-allocate in base64 encoding and decoding (#1751)
This commit is contained in:
parent
fcd180891b
commit
dac6885fb0
@ -390,7 +390,7 @@ char* s3fs_base64(const unsigned char* input, size_t length)
|
|||||||
if(!input || 0 == length){
|
if(!input || 0 == length){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
result = new char[((length / 3) + 1) * 4 + 1];
|
result = new char[((length + 3 - 1) / 3) * 4 + 1];
|
||||||
|
|
||||||
unsigned char parts[4];
|
unsigned char parts[4];
|
||||||
size_t rpos;
|
size_t rpos;
|
||||||
@ -438,7 +438,7 @@ unsigned char* s3fs_decode64(const char* input, size_t* plength)
|
|||||||
if(!input || 0 == strlen(input) || !plength){
|
if(!input || 0 == strlen(input) || !plength){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
result = new unsigned char[strlen(input) + 1];
|
result = new unsigned char[strlen(input) / 4 * 3 + 1];
|
||||||
|
|
||||||
unsigned char parts[4];
|
unsigned char parts[4];
|
||||||
size_t input_len = strlen(input);
|
size_t input_len = strlen(input);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user