[openssh-commits] [openssh] 01/01: Fuzzer harness for sshsig

git+noreply at mindrot.org git+noreply at mindrot.org
Thu Sep 5 14:26:49 AEST 2019


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit f4846dfc6a79f84bbc6356ae3184f142bacedc24
Author: Damien Miller <djm at mindrot.org>
Date:   Thu Sep 5 11:09:28 2019 +1000

    Fuzzer harness for sshsig
---
 regress/misc/fuzz-harness/Makefile       |  5 ++++-
 regress/misc/fuzz-harness/sshsig_fuzz.cc | 35 ++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/regress/misc/fuzz-harness/Makefile b/regress/misc/fuzz-harness/Makefile
index a2aa4441..6ab7d721 100644
--- a/regress/misc/fuzz-harness/Makefile
+++ b/regress/misc/fuzz-harness/Makefile
@@ -7,7 +7,7 @@ CXXFLAGS=-O2 -g -Wall -Wextra -I ../../.. $(FUZZ_FLAGS)
 LDFLAGS=-L ../../.. -L ../../../openbsd-compat -g $(FUZZ_FLAGS)
 LIBS=-lssh -lopenbsd-compat -lcrypto $(FUZZ_LIBS)
 
-all: pubkey_fuzz sig_fuzz authopt_fuzz
+all: pubkey_fuzz sig_fuzz authopt_fuzz sshsig_fuzz
 
 .cc.o:
 	$(CXX) $(CXXFLAGS) -c $< -o $@
@@ -21,5 +21,8 @@ sig_fuzz: sig_fuzz.o
 authopt_fuzz: authopt_fuzz.o
 	$(CXX) -o $@ authopt_fuzz.o ../../../auth-options.o $(LDFLAGS) $(LIBS)
 
+sshsig_fuzz: sshsig_fuzz.o
+	$(CXX) -o $@ sshsig_fuzz.o ../../../sshsig.o $(LDFLAGS) $(LIBS)
+
 clean:
 	-rm -f *.o pubkey_fuzz sig_fuzz authopt_fuzz
diff --git a/regress/misc/fuzz-harness/sshsig_fuzz.cc b/regress/misc/fuzz-harness/sshsig_fuzz.cc
new file mode 100644
index 00000000..fe09ccb8
--- /dev/null
+++ b/regress/misc/fuzz-harness/sshsig_fuzz.cc
@@ -0,0 +1,35 @@
+// cc_fuzz_target test for sshsig verification.
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern "C" {
+
+#include "includes.h"
+#include "sshkey.h"
+#include "ssherr.h"
+#include "sshbuf.h"
+#include "sshsig.h"
+#include "log.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t* sig, size_t slen)
+{
+  static const char *data = "If everyone started announcing his nose had "
+      "run away, I don’t know how it would all end";
+  struct sshbuf *signature = sshbuf_from(sig, slen);
+  struct sshbuf *message = sshbuf_from(data, strlen(data));
+  struct sshkey *k = NULL;
+  extern char *__progname;
+
+  log_init(__progname, SYSLOG_LEVEL_QUIET, SYSLOG_FACILITY_USER, 1);
+  sshsig_verifyb(signature, message, "castle", &k);
+  sshkey_free(k);
+  sshbuf_free(signature);
+  sshbuf_free(message);
+  return 0;
+}
+
+} // extern

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list