mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 12:40:51 +02:00
reallocate tmp buffer with space for null terminator
This commit is contained in:
@@ -177,6 +177,16 @@ static int LoadFile(const char* filename, byte** buf, word32* bufSz, int* isPem)
|
||||
|
||||
/* Check if PEM format by looking for -----BEGIN */
|
||||
if (isPem) {
|
||||
/* Reallocate with space for null terminator for XSTRSTR */
|
||||
byte* tmp = (byte*)XREALLOC(*buf, (word32)sz + 1, NULL,
|
||||
DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (tmp == NULL) {
|
||||
XFREE(*buf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
*buf = NULL;
|
||||
return MEMORY_E;
|
||||
}
|
||||
*buf = tmp;
|
||||
(*buf)[sz] = '\0';
|
||||
*isPem = (XSTRSTR((char*)*buf, "-----BEGIN") != NULL) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user