Merge pull request #595 from danielinux/fix_malloc_pkcs11_store

Fix malloc in pkcs11_store
pull/602/head
David Garske 2025-10-06 13:28:27 -07:00 committed by GitHub
commit 21707c7e3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 7 deletions

View File

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

View File

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