postgresql: fix build (#8963)

Ref: https://github.com/google/oss-fuzz/pull/8948

Signed-off-by: David Korczynski <david@adalogics.com>

Signed-off-by: David Korczynski <david@adalogics.com>
This commit is contained in:
DavidKorczynski 2022-11-10 02:05:42 +01:00 committed by GitHub
parent 630c5ebc0e
commit e04e7b44ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View File

@ -39,8 +39,8 @@ index 0775abe35d..f53b3580b3 100644
+ {
+#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
+
AssertArg(dbname != NULL);
AssertArg(username != NULL);
Assert(dbname != NULL);
Assert(username != NULL);
@@ -4312,6 +4325,11 @@ PostgresMain(const char *dbname, const char *username)
if (!ignore_till_sync)

View File

@ -22,7 +22,7 @@ objfiles.txt: Makefile $(SUBDIROBJS) $(OBJS_FUZZERS)
SUBDIRS = ../access ../bootstrap ../catalog ../parser ../commands ../executor ../foreign ../lib ../libpq \
../main ../nodes ../optimizer ../partitioning ../port ../postmaster \
../regex ../replication ../rewrite \
../regex ../replication ../rewrite ../backup \
../statistics ../storage ../tcop ../tsearch ../utils $(top_builddir)/src/timezone \
../jit
@ -41,13 +41,13 @@ fuzzer: simple_query_fuzzer \
protocol_fuzzer
simple_query_fuzzer json_parser_fuzzer: %: %.o fuzzer_initialize.o $(OBJS_FUZZERS)
$(CXX) $(CFLAGS) $(call expand_subsys,$^) -o $@ $(LIB_FUZZING_ENGINE)
$(CXX) $(CFLAGS) $(call expand_subsys,$^) -o $@ $(LIB_FUZZING_ENGINE) -lz
simple_query_fuzzer.o json_parser_fuzzer.o protocol_fuzzer.o fuzzer_initialize.o: %.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $^
protocol_fuzzer: %: %.o $(OBJS_FUZZERS)
$(CXX) $(CFLAGS) $(call expand_subsys,$^) -o $@ $(LIB_FUZZING_ENGINE) -Wl,--wrap=exit -Wl,--wrap=pq_getbyte
$(CXX) $(CFLAGS) $(call expand_subsys,$^) -o $@ $(LIB_FUZZING_ENGINE) -Wl,--wrap=exit -Wl,--wrap=pq_getbyte -lz
dbfuzz: dbfuzz.o | submake-libpgport temp-install
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@ \

View File

@ -86,7 +86,7 @@ int FuzzerInitialize(char *dbname, char ***argv){
InitProcess();
BaseInit();
PG_SETMASK(&UnBlockSig);
InitPostgres("dbfuzz", InvalidOid, username, InvalidOid, NULL, false);
InitPostgres("dbfuzz", InvalidOid, username, InvalidOid, false, false, NULL);
SetProcessingMode(NormalProcessing);

View File

@ -79,7 +79,7 @@ exec_simple_query(const char *query_string)
else
oldcontext = MemoryContextSwitchTo(MessageContext);
querytree_list = pg_analyze_and_rewrite(parsetree, query_string,
querytree_list = pg_analyze_and_rewrite_fixedparams(parsetree, query_string,
NULL, 0, NULL);
plantree_list = pg_plan_queries(querytree_list, query_string,
@ -124,7 +124,6 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
AbortCurrentTransaction();
PortalErrorCleanup();
SPICleanup();
jit_reset_after_error();