]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add fuzzing stuff in libfrr
authorQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 11 Dec 2019 21:37:38 +0000 (16:37 -0500)
committerQuentin Young <qlyoung@nvidia.com>
Mon, 15 Nov 2021 19:42:31 +0000 (14:42 -0500)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/fuzz.h [new file with mode: 0644]
lib/zebra.h

diff --git a/lib/fuzz.h b/lib/fuzz.h
new file mode 100644 (file)
index 0000000..04c48c8
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Utilities for fuzzing frr.
+ */
+#ifndef __FUZZ_H__
+#define __FUZZ_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+static inline int frrfuzz_read_input(uint8_t **input)
+{
+       fseek(stdin, 0, SEEK_END);
+       long fsize = ftell(stdin);
+       if (fsize < 0)
+               return 0;
+
+       *input = (uint8_t *)malloc(fsize);
+
+       fseek(stdin, 0, SEEK_SET);
+       int r = fread(*input, 1, fsize, stdin);
+
+       return r;
+}
+
+#endif /* __FUZZ_H__ */
index 0a5e652bb15f3ab66aa76a83e336f1f91e84376f..332a8bd75804ace39862a2a808ac921b8a45657a 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define FUZZING 1
 #ifndef _ZEBRA_H
 #define _ZEBRA_H
 
+#define FUZZING 1
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
 #include <endian.h>
 #endif
 
+
+#ifdef FUZZING
+#include "fuzz.h"
+#endif
+
+
 /* machine dependent includes */
 #ifdef HAVE_LINUX_VERSION_H
 #include <linux/version.h>