diff --git a/MaraDns.h b/MaraDns.h index 176c26c..65528e7 100644 --- a/MaraDns.h +++ b/MaraDns.h @@ -111,7 +111,11 @@ /* Whether we allow MaraDNS to run as a non root user; this is usually * disabled, but can be enabled by uncommenting the following line */ -/* #define ALLOW_NON_ROOT */ +#define ALLOW_NON_ROOT + +/* Define to read the packets from stdin instead of UDP sockets, + * it still needs valid configuration and socket it can bind to */ +#define FUZZING /* The maximum allowed size of a zone name */ #define MAX_ZONE_SIZE 256 diff --git a/server/MaraDNS.c b/server/MaraDNS.c index 82eb77e..64c40b1 100644 --- a/server/MaraDNS.c +++ b/server/MaraDNS.c @@ -4545,7 +4545,11 @@ int main(int argc, char **argv) { if(log_level >= 3) mlog(L_DATAWAIT); /* "Awaiting data on port 53" */ /* Listen for data on the UDP socket */ +#ifndef FUZZING for(;;) { +#else + do { +#endif int sock_num; conn ect; /* The space is not a typo */ ect.type = 0; @@ -4561,8 +4565,19 @@ int main(int argc, char **argv) { qual_set_time(); if(log_level >= 50) /* This happens once a second */ mlog(L_DATAWAIT); /* "Awaiting data on port 53" */ +#ifndef FUZZING sock_num = getudp(sock,bind_addresses,&ect,incoming,512, have_ipv6_address); +#else + sock_num = read(0, incoming, 512); + if (sock_num == 0) { + continue; + } else if (sock_num < 0) { + break; + } else { + sock_num = 0; + } +#endif if(sock_num == JS_ERROR) continue; if(log_level >= 3) @@ -4660,6 +4675,9 @@ int main(int argc, char **argv) { js_dealloc(ect.d); } } +#ifdef FUZZING + while(0); +#endif /* We should never end up here */