mirror of
https://github.com/espressif/openthread.git
synced 2026-09-02 15:20:07 +00:00
[fuzz] load only value enum values (#11573)
This commit is contained in:
@@ -62,6 +62,20 @@ public:
|
||||
return buf;
|
||||
}
|
||||
|
||||
uint8_t ConsumeIntegralInRange(uint8_t aMin, uint8_t aMax)
|
||||
{
|
||||
assert(aMin < aMax);
|
||||
|
||||
uint16_t range = aMax - aMin;
|
||||
uint8_t result;
|
||||
|
||||
ConsumeData(&result, sizeof(result));
|
||||
|
||||
result = result % (range + 1);
|
||||
|
||||
return result + aMin;
|
||||
}
|
||||
|
||||
size_t RemainingBytes(void) { return mSize; }
|
||||
|
||||
private:
|
||||
@@ -114,8 +128,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
Log("---------------------------------------------------------------------------------------");
|
||||
Log("Fuzz");
|
||||
|
||||
fdp.ConsumeData(&error, sizeof(error));
|
||||
VerifyOrExit((OT_ERROR_NONE <= error) && (error < OT_NUM_ERRORS));
|
||||
error = static_cast<otError>(fdp.ConsumeIntegralInRange(OT_ERROR_NONE, OT_NUM_ERRORS - 1));
|
||||
|
||||
fdp.ConsumeData(&frame, sizeof(frame));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user