oss-fuzz/projects/postgresql/add_fuzzers.diff

39 lines
1.4 KiB
Diff
Raw Normal View History

diff --git a/src/backend/Makefile b/src/backend/Makefile
index 9706a95848..4312c346a4 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -43,6 +43,8 @@ OBJS = \
$(top_builddir)/src/common/libpgcommon_srv.a \
$(top_builddir)/src/port/libpgport_srv.a
+OBJS_WITHOUT_MAIN = $(filter-out main/objfiles.txt, $(OBJS))
+
# We put libpgport and libpgcommon into OBJS, so remove it from LIBS; also add
# libldap and ICU
LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE) $(ICU_LIBS)
@@ -56,7 +58,10 @@ endif
##########################################################################
-all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
+all: submake-libpgport submake-catalog-headers submake-utils-headers postgres fuzzer $(POSTGRES_IMP)
+
+fuzzer: fuzzer/simple_query_fuzzer \
+ fuzzer/json_parser_fuzzer
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
@@ -65,6 +70,12 @@ ifneq ($(PORTNAME), aix)
postgres: $(OBJS)
$(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(LIBS) -o $@
+fuzzer/json_parser_fuzzer: fuzzer/json_parser_fuzzer.o $(OBJS_WITHOUT_MAIN)
+ $(CXX) $(CFLAGS) $(call expand_subsys,$^) -o $@ $(LIB_FUZZING_ENGINE)
+
+fuzzer/simple_query_fuzzer: fuzzer/simple_query_fuzzer.o $(OBJS_WITHOUT_MAIN)
+ $(CXX) $(CFLAGS) $(call expand_subsys,$^) -o $@ $(LIB_FUZZING_ENGINE)
+
endif
endif
endif