Skip to content

Commit

Permalink
[fuzz] fix typo and enable SRP Advertising Proxy
Browse files Browse the repository at this point in the history
This commit fixes the typo and enables SRP_ADV_PROXY - also by turning
on the dependent components.

Signed-off-by: Łukasz Duda <[email protected]>
  • Loading branch information
LuDuda committed May 27, 2024
1 parent 34b1a30 commit f43ef39
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/cli/cli_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,22 @@ template <> otError TcpExample::Process<Cmd("init")>(Arg aArgs[])
mInitialized = true;

exit:
#if OPENTHREAD_CONFIG_TLS_ENABLE
if ((error != OT_ERROR_NONE) && mUseTls)
if (error != OT_ERROR_NONE)
{
mbedtls_ssl_config_free(&mSslConfig);
mbedtls_ssl_free(&mSslContext);
#if OPENTHREAD_CONFIG_TLS_ENABLE
if (mUseTls)
{
mbedtls_ssl_config_free(&mSslConfig);
mbedtls_ssl_free(&mSslContext);

mbedtls_pk_free(&mPKey);
mbedtls_x509_crt_free(&mSrvCert);
mbedtls_pk_free(&mPKey);
mbedtls_x509_crt_free(&mSrvCert);
}
#endif // OPENTHREAD_CONFIG_TLS_ENABLE

otTcpCircularSendBufferForceDiscardAll(&mSendBuffer);
OT_UNUSED_VARIABLE(otTcpCircularSendBufferDeinitialize(&mSendBuffer));
}
#endif // OPENTHREAD_CONFIG_TLS_ENABLE

return error;
}
Expand Down
130 changes: 130 additions & 0 deletions tests/fuzz/fuzzer_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
#include <openthread/platform/alarm-micro.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include <openthread/platform/dnssd.h>
#include <openthread/platform/entropy.h>
#include <openthread/platform/logging.h>
#include <openthread/platform/mdns_socket.h>
#include <openthread/platform/misc.h>
#include <openthread/platform/multipan.h>
#include <openthread/platform/radio.h>
Expand Down Expand Up @@ -147,6 +149,8 @@ void FuzzerPlatformProcess(otInstance *aInstance)

bool FuzzerPlatformResetWasRequested(void) { return sResetWasRequested; }

extern "C" {

uint32_t otPlatAlarmMilliGetNow(void) { return sAlarmNow / 1000; }

void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
Expand Down Expand Up @@ -515,3 +519,129 @@ void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otErro
}

void otPlatDiagAlarmCallback(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }

otPlatDnssdState otPlatDnssdGetState(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);

return OT_PLAT_DNSSD_STOPPED;
}

void otPlatDnssdRegisterService(otInstance *aInstance,
const otPlatDnssdService *aService,
otPlatDnssdRequestId aRequestId,
otPlatDnssdRegisterCallback aCallback)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aService);
OT_UNUSED_VARIABLE(aRequestId);
OT_UNUSED_VARIABLE(aCallback);
}

void otPlatDnssdUnregisterService(otInstance *aInstance,
const otPlatDnssdService *aService,
otPlatDnssdRequestId aRequestId,
otPlatDnssdRegisterCallback aCallback)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aService);
OT_UNUSED_VARIABLE(aRequestId);
OT_UNUSED_VARIABLE(aCallback);
}

void otPlatDnssdRegisterHost(otInstance *aInstance,
const otPlatDnssdHost *aHost,
otPlatDnssdRequestId aRequestId,
otPlatDnssdRegisterCallback aCallback)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aHost);
OT_UNUSED_VARIABLE(aRequestId);
OT_UNUSED_VARIABLE(aCallback);
}

void otPlatDnssdUnregisterHost(otInstance *aInstance,
const otPlatDnssdHost *aHost,
otPlatDnssdRequestId aRequestId,
otPlatDnssdRegisterCallback aCallback)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aHost);
OT_UNUSED_VARIABLE(aRequestId);
OT_UNUSED_VARIABLE(aCallback);
}

void otPlatDnssdRegisterKey(otInstance *aInstance,
const otPlatDnssdKey *aKey,
otPlatDnssdRequestId aRequestId,
otPlatDnssdRegisterCallback aCallback)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aKey);
OT_UNUSED_VARIABLE(aRequestId);
OT_UNUSED_VARIABLE(aCallback);
}

void otPlatDnssdUnregisterKey(otInstance *aInstance,
const otPlatDnssdKey *aKey,
otPlatDnssdRequestId aRequestId,
otPlatDnssdRegisterCallback aCallback)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aKey);
OT_UNUSED_VARIABLE(aRequestId);
OT_UNUSED_VARIABLE(aCallback);
}

otError otPlatMdnsSetListeningEnabled(otInstance *aInstance, bool aEnable, uint32_t aInfraIfIndex)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aEnable);
OT_UNUSED_VARIABLE(aInfraIfIndex);

return OT_ERROR_NOT_IMPLEMENTED;
}

void otPlatMdnsSendMulticast(otInstance *aInstance, otMessage *aMessage, uint32_t aInfraIfIndex)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aMessage);
OT_UNUSED_VARIABLE(aInfraIfIndex);
}

void otPlatMdnsSendUnicast(otInstance *aInstance, otMessage *aMessage, const otPlatMdnsAddressInfo *aAddress)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aMessage);
OT_UNUSED_VARIABLE(aAddress);
}

bool otPlatInfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddress)
{
OT_UNUSED_VARIABLE(aInfraIfIndex);
OT_UNUSED_VARIABLE(aAddress);

return false;
}

otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
const otIp6Address *aDestAddress,
const uint8_t *aBuffer,
uint16_t aBufferLength)
{
OT_UNUSED_VARIABLE(aInfraIfIndex);
OT_UNUSED_VARIABLE(aDestAddress);
OT_UNUSED_VARIABLE(aBuffer);
OT_UNUSED_VARIABLE(aBufferLength);

return OT_ERROR_FAILED;
}

otError otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex)
{
OT_UNUSED_VARIABLE(aInfraIfIndex);

return OT_ERROR_FAILED;
}

} // extern "C"
5 changes: 4 additions & 1 deletion tests/fuzz/oss-fuzz-build
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set -euxo pipefail
-DOT_RCP=OFF \
-DOT_BORDER_AGENT=ON \
-DOT_BORDER_ROUTER=ON \
-DOT_BORDER_ROUTING=ON \
-DOT_CHANNEL_MANAGER=ON \
-DOT_CHANNEL_MONITOR=ON \
-DOT_COAP=ON \
Expand All @@ -55,6 +56,7 @@ set -euxo pipefail
-DOT_DHCP6_CLIENT=ON \
-DOT_DHCP6_SERVER=ON \
-DOT_DNS_CLIENT=ON \
-DOT_DNSSD_SERVER=ON \
-DOT_ECDSA=ON \
-DOT_HISTORY_TRACKER=ON \
-DOT_IP6_FRAGM=ON \
Expand All @@ -63,13 +65,14 @@ set -euxo pipefail
-DOT_LINK_RAW=ON \
-DOT_LOG_OUTPUT=APP \
-DOT_MAC_FILTER=ON \
-DOT_MDNS=ON \
-DOT_NETDATA_PUBLISHER=ON \
-DOT_NETDIAG_CLIENT=ON \
-DOT_PING_SENDER=ON \
-DOT_SERVICE=ON \
-DOT_SLAAC=ON \
-DOT_SNTP_CLIENT=ON \
-DOT_SRN_ADV_PROXY=ON \
-DOT_SRP_ADV_PROXY=ON \
-DOT_SRP_CLIENT=ON \
-DOT_SRP_SERVER=ON \
-DOT_THREAD_VERSION=1.3 \
Expand Down

0 comments on commit f43ef39

Please sign in to comment.