mirror of https://github.com/wolfSSL/wolfBoot.git
Merge pull request #595 from danielinux/fix_malloc_pkcs11_store
Fix malloc in pkcs11_storepull/602/head
commit
21707c7e3b
|
|
@ -652,6 +652,7 @@ ifeq ($(WOLFCRYPT_TZ_PKCS11),1)
|
|||
CFLAGS+=-DCK_CALLABLE="__attribute__((cmse_nonsecure_entry))"
|
||||
CFLAGS+=-I$(WOLFBOOT_LIB_WOLFPKCS11)
|
||||
CFLAGS+=-DWP11_HASH_PIN_COST=3
|
||||
LDFLAGS+=--specs=nano.specs
|
||||
WOLFCRYPT_OBJS+=src/pkcs11_store.o
|
||||
WOLFCRYPT_OBJS+=src/pkcs11_callable.o
|
||||
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/pwdbased.o
|
||||
|
|
|
|||
|
|
@ -66,19 +66,16 @@ extern unsigned int _heap_size; /* From linker script: heap limit */
|
|||
void * _sbrk(unsigned int incr)
|
||||
{
|
||||
static unsigned char *heap = (unsigned char *)&_start_heap;
|
||||
static uint32_t heapsize = (uint32_t)(&_heap_size);
|
||||
static uint32_t heapsize = (uintptr_t)&_heap_size;
|
||||
void *old_heap = heap;
|
||||
if (((incr >> 2) << 2) != incr)
|
||||
incr = ((incr >> 2) + 1) << 2;
|
||||
|
||||
if (heap == NULL)
|
||||
if (heap == NULL) {
|
||||
heap = (unsigned char *)&_start_heap;
|
||||
else
|
||||
old_heap = heap;
|
||||
} else
|
||||
heap += incr;
|
||||
if (((uint32_t)heap - (uint32_t)(&_start_heap)) > heapsize) {
|
||||
heap -= incr;
|
||||
return NULL;
|
||||
}
|
||||
return old_heap;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue