Merge pull request #2847 from akallabeth/base64_decode_ensure_null_termination
Ensure output of crypto_base64_decode is NULL terminated.
This commit is contained in:
commit
157f5af99b
@ -124,7 +124,7 @@ static void* base64_decode(const char* s, int length, int* data_len)
|
||||
if (length % 4)
|
||||
return NULL;
|
||||
|
||||
q = data = (BYTE*) malloc(length / 4 * 3);
|
||||
q = data = (BYTE*) malloc(length / 4 * 3 + 1);
|
||||
if (!q)
|
||||
return NULL;
|
||||
|
||||
@ -184,6 +184,7 @@ static void* base64_decode(const char* s, int length, int* data_len)
|
||||
}
|
||||
|
||||
*data_len = outputLen;
|
||||
data[outputLen] = '\0';
|
||||
|
||||
return data;
|
||||
out_free:
|
||||
|
Loading…
Reference in New Issue
Block a user