tests: Limit maximum number of frames in fuzzing tests

This limits the EAP-SIM and EAP-AKA tests to 100 test frames to avoid
undesired timeouts in automated fuzz testing. The real world uses are
limited to 50 rounds, so there is not really any point in trying with
thousands of frames.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2021-05-04 18:19:23 +03:00 committed by Jouni Malinen
parent 6ae0d78b8e
commit fd4580e1e8
2 changed files with 6 additions and 2 deletions

View file

@ -91,6 +91,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
struct eap_sm *sm; struct eap_sm *sm;
void *priv; void *priv;
struct eap_method_ret ret; struct eap_method_ret ret;
unsigned int count = 0;
wpa_fuzzer_set_debug_level(); wpa_fuzzer_set_debug_level();
@ -104,7 +105,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
pos = data; pos = data;
end = pos + size; end = pos + size;
while (end - pos > 2) { while (end - pos > 2 && count < 100) {
u16 flen; u16 flen;
struct wpabuf *buf, *req; struct wpabuf *buf, *req;
@ -121,6 +122,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
wpabuf_free(req); wpabuf_free(req);
wpabuf_free(buf); wpabuf_free(buf);
pos += flen; pos += flen;
count++;
} }
registered_eap_method->deinit(sm, priv); registered_eap_method->deinit(sm, priv);

View file

@ -85,6 +85,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
struct eap_sm *sm; struct eap_sm *sm;
void *priv; void *priv;
struct eap_method_ret ret; struct eap_method_ret ret;
unsigned int count = 0;
wpa_fuzzer_set_debug_level(); wpa_fuzzer_set_debug_level();
@ -98,7 +99,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
pos = data; pos = data;
end = pos + size; end = pos + size;
while (end - pos > 2) { while (end - pos > 2 && count < 100) {
u16 flen; u16 flen;
struct wpabuf *buf, *req; struct wpabuf *buf, *req;
@ -115,6 +116,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
wpabuf_free(req); wpabuf_free(req);
wpabuf_free(buf); wpabuf_free(buf);
pos += flen; pos += flen;
count++;
} }
registered_eap_method->deinit(sm, priv); registered_eap_method->deinit(sm, priv);