diff options
Diffstat (limited to 'devel/fuzz/gnutls_psk_client_fuzzer.cc')
-rw-r--r-- | devel/fuzz/gnutls_psk_client_fuzzer.cc | 46 |
1 files changed, 4 insertions, 42 deletions
diff --git a/devel/fuzz/gnutls_psk_client_fuzzer.cc b/devel/fuzz/gnutls_psk_client_fuzzer.cc index 35b85f64c5..0d622dcf8e 100644 --- a/devel/fuzz/gnutls_psk_client_fuzzer.cc +++ b/devel/fuzz/gnutls_psk_client_fuzzer.cc @@ -32,45 +32,7 @@ #include <gnutls/gnutls.h> #include "psk.h" - -struct mem_st { - const uint8_t *data; - size_t size; -}; - -#define MIN(x,y) ((x)<(y)?(x):(y)) -static ssize_t -client_push(gnutls_transport_ptr_t tr, const void *data, size_t len) -{ - return len; -} - -static ssize_t client_pull(gnutls_transport_ptr_t tr, void *data, size_t len) -{ - struct mem_st *p = (struct mem_st *)tr; - - if (p->size == 0) { - return 0; - } - - len = MIN(len, p->size); - memcpy(data, p->data, len); - - p->size -= len; - p->data += len; - - return len; -} - -int client_pull_timeout_func(gnutls_transport_ptr_t tr, unsigned int ms) -{ - struct mem_st *p = (struct mem_st *)tr; - - if (p->size > 0) - return 1; /* available data */ - else - return 0; /* timeout */ -} +#include "mem.h" #ifdef __cplusplus extern "C" @@ -104,10 +66,10 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size) memdata.data = data; memdata.size = size; - gnutls_transport_set_push_function(session, client_push); - gnutls_transport_set_pull_function(session, client_pull); + gnutls_transport_set_push_function(session, mem_push); + gnutls_transport_set_pull_function(session, mem_pull); gnutls_transport_set_pull_timeout_function(session, - client_pull_timeout_func); + mem_pull_timeout); gnutls_transport_set_ptr(session, &memdata); do { |