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:
Martin Fleisz 2015-08-27 11:28:37 +02:00
commit 157f5af99b

View File

@ -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: