Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
LuDuda committed May 23, 2024
1 parent 26ac34a commit 4224401
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 16 additions & 0 deletions tests/fuzz/cli_received.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#include <openthread/cli.h>
#include <openthread/instance.h>
Expand Down Expand Up @@ -68,6 +69,19 @@ void AdvanceTime(otInstance *aInstance, uint32_t aDuration)
}
}

static uint64_t gCounter = 0;

void *otPlatCAlloc(size_t aNum, size_t aSize) {
gCounter++;
return calloc(aNum, aSize);
}

void otPlatFree(void *aPtr) {
gCounter--;
free(aPtr);
}


extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
const otPanId panId = 0xdead;
Expand Down Expand Up @@ -110,5 +124,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
otInstanceFinalize(instance);
}

assert(gCounter == 0);

return 0;
}
8 changes: 4 additions & 4 deletions third_party/mbedtls/mbedtls-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@
#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */
#define MBEDTLS_ENTROPY_MAX_SOURCES 1 /**< Maximum number of sources supported */

#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
//#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
#define MBEDTLS_PLATFORM_STD_CALLOC otPlatCAlloc /**< Default allocator to use, can be undefined */
#define MBEDTLS_PLATFORM_STD_FREE otPlatFree /**< Default free to use, can be undefined */
#else
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
#endif
//#else
//#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
//#endif

#if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
#define MBEDTLS_SSL_MAX_CONTENT_LEN 2000 /**< Maxium fragment length in bytes */
Expand Down

0 comments on commit 4224401

Please sign in to comment.