Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get ntp-dev fuzzing again #11589

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions projects/ntp/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
cd ntp-dev
git apply ../patch.diff
#avoids https://bugs.llvm.org/show_bug.cgi?id=34636
cp /usr/bin/ld.gold /usr/bin/ld
#not a problem with binutils 2.36+
#cp /usr/bin/ld.gold /usr/bin/ld
./bootstrap
./configure --enable-fuzztargets
./configure -C --enable-fuzztargets --disable-dependency-tracking
make
cp tests/fuzz/fuzz_ntpd_receive $OUT/
19 changes: 9 additions & 10 deletions projects/ntp/patch.diff
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ diff --git a/configure.ac b/configure.ac
index 7975d31..528861c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4399,6 +4399,37 @@ AC_DEFINE_UNQUOTED([DYNAMIC_INTERLEAVE], [$ntp_dynamic_interleave],
[support dynamic interleave?])
AC_MSG_RESULT([$ntp_ok])
@@ -4429,6 +4429,37 @@
#define NONEMPTY_TRANSLATION_UNIT extern int abs(int);
])

+AC_ARG_ENABLE(fuzztargets,
+ AS_HELP_STRING([--enable-fuzztargets], [Enable fuzz targets]),[enable_fuzztargets=$enableval],[enable_fuzztargets=no])
Expand Down Expand Up @@ -39,8 +39,8 @@ index 7975d31..528861c 100644
+
NTP_UNITYBUILD

dnl gtest is needed for our tests subdirs. It would be nice if we could
@@ -4459,6 +4490,7 @@ AC_CONFIG_FILES([tests/ntpd/Makefile])
NTP_PROBLEM_TESTS
@@ -4484,6 +4515,7 @@
AC_CONFIG_FILES([tests/ntpq/Makefile])
AC_CONFIG_FILES([tests/sandbox/Makefile])
AC_CONFIG_FILES([tests/sec-2853/Makefile])
Expand All @@ -52,7 +52,7 @@ diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c
index 7c3fdd4..190a373 100644
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -503,7 +503,11 @@ io_open_sockets(void)
@@ -510,7 +510,11 @@
* Create the sockets
*/
BLOCKIO();
Expand Down Expand Up @@ -99,7 +99,7 @@ new file mode 100644
index 0000000..7cb8d99
--- /dev/null
+++ b/tests/fuzz/fuzz_ntpd_receive.c
@@ -0,0 +1,94 @@
@@ -0,0 +1,93 @@
+#include <stddef.h>
+#include <stdint.h>
+#include <sys/types.h>
Expand All @@ -110,14 +110,13 @@ index 0000000..7cb8d99
+#include "recvbuff.h"
+#include "ntpd.h"
+
+const char *Version = "libntpq 0.3beta";
+const char *Version = "fuzz_ntpd_receive 0.2";
+int listen_to_virtual_ips = TRUE;
+int mdnstries = 5;
+char const *progname = "fuzz_ntpd_receive";
+#ifdef HAVE_WORKING_FORK
+int waitsync_fd_to_close = -1; /* -w/--wait-sync */
+int daemon_pipe[2] = {-1, -1}; /* -w/--wait-sync */
+#endif
+int yydebug=0;
+
+static int initialized = 0;
+int sockfd;
Expand Down
2 changes: 2 additions & 0 deletions projects/ntp/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ primary_contact: "security@ntp.org"
main_repo: "https://bitbucket.nwtime.org/scm/websites/ntpwww.git"
auto_ccs:
- "p.antoine@catenacyber.fr"
- "hart@ntp.org"
- "stenn@nwtime.org"
fuzzing_engines:
- afl
- libfuzzer
Expand Down