[openssh-commits] [openssh] 01/01: add a fuzzer for private key parsing

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Oct 9 13:49:59 AEDT 2019


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

djm pushed a commit to branch master
in repository openssh.

commit 1ba130ac8fb2884307f658126f04578f8aef409e
Author: Damien Miller <djm at mindrot.org>
Date:   Wed Oct 9 13:49:35 2019 +1100

    add a fuzzer for private key parsing
---
 regress/misc/fuzz-harness/Makefile        |  6 +++++-
 regress/misc/fuzz-harness/privkey_fuzz.cc | 21 +++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/regress/misc/fuzz-harness/Makefile b/regress/misc/fuzz-harness/Makefile
index 85179ac4..e164e886 100644
--- a/regress/misc/fuzz-harness/Makefile
+++ b/regress/misc/fuzz-harness/Makefile
@@ -7,7 +7,8 @@ CXXFLAGS=-O2 -g -Wall -Wextra -I ../../.. $(FUZZ_FLAGS)
 LDFLAGS=-L ../../.. -L ../../../openbsd-compat -g $(FUZZ_FLAGS)
 LIBS=-lssh -lopenbsd-compat -lcrypto $(FUZZ_LIBS)
 
-TARGETS=pubkey_fuzz sig_fuzz authopt_fuzz sshsig_fuzz sshsigopt_fuzz
+TARGETS=pubkey_fuzz sig_fuzz authopt_fuzz sshsig_fuzz \
+	sshsigopt_fuzz privkey_fuzz
 
 all: $(TARGETS)
 
@@ -29,5 +30,8 @@ sshsig_fuzz: sshsig_fuzz.o
 sshsigopt_fuzz: sshsigopt_fuzz.o
 	$(CXX) -o $@ sshsigopt_fuzz.o ../../../sshsig.o $(LDFLAGS) $(LIBS)
 
+privkey_fuzz: privkey_fuzz.o
+	$(CXX) -o $@ privkey_fuzz.o $(LDFLAGS) $(LIBS)
+
 clean:
 	-rm -f *.o $(TARGETS)
diff --git a/regress/misc/fuzz-harness/privkey_fuzz.cc b/regress/misc/fuzz-harness/privkey_fuzz.cc
new file mode 100644
index 00000000..ff0b0f77
--- /dev/null
+++ b/regress/misc/fuzz-harness/privkey_fuzz.cc
@@ -0,0 +1,21 @@
+#include <stddef.h>
+#include <stdio.h>
+#include <stdint.h>
+
+extern "C" {
+
+#include "sshkey.h"
+#include "sshbuf.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+	struct sshkey *k = NULL;
+	struct sshbuf *b = sshbuf_from(data, size);
+	int r = sshkey_private_deserialize(b, &k);
+	if (r == 0) sshkey_free(k);
+	sshbuf_free(b);
+	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