mirror of https://github.com/google/oss-fuzz.git
postgresql: fix build (#6570)
* postgresql: fix build * update PostgresMain params * use PostgresSingle following updates in postgres * postgresql tmp fix * fix build
This commit is contained in:
parent
985bbb0971
commit
af7ef0f6be
|
@ -1,26 +1,27 @@
|
|||
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
|
||||
index 825fd55107..f3e2dbbf20 100644
|
||||
index 0775abe35d..f53b3580b3 100644
|
||||
--- a/src/backend/tcop/postgres.c
|
||||
+++ b/src/backend/tcop/postgres.c
|
||||
@@ -105,6 +105,10 @@ int PostAuthDelay = 0;
|
||||
@@ -105,6 +105,11 @@ int PostAuthDelay = 0;
|
||||
/* Time between checks that the client is still connected. */
|
||||
int client_connection_check_interval = 0;
|
||||
|
||||
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
+bool fuzzer_first_run = true;
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
/* ----------------
|
||||
* private typedefs etc
|
||||
* ----------------
|
||||
@@ -454,10 +458,15 @@ ReadCommand(StringInfo inBuf)
|
||||
@@ -471,11 +476,14 @@ static int
|
||||
ReadCommand(StringInfo inBuf)
|
||||
{
|
||||
int result;
|
||||
|
||||
-
|
||||
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
+ result = SocketBackend(inBuf);
|
||||
+ result = SocketBackend(inBuf);
|
||||
+#else
|
||||
+
|
||||
if (whereToSendOutput == DestRemote)
|
||||
result = SocketBackend(inBuf);
|
||||
else
|
||||
|
@ -29,19 +30,19 @@ index 825fd55107..f3e2dbbf20 100644
|
|||
return result;
|
||||
}
|
||||
|
||||
@@ -3910,6 +3919,11 @@ PostgresMain(int argc, char *argv[],
|
||||
@@ -4021,6 +4029,11 @@ PostgresMain(const char *dbname, const char *username)
|
||||
bool idle_in_transaction_timeout_enabled = false;
|
||||
bool idle_session_timeout_enabled = false;
|
||||
|
||||
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
+ if(fuzzer_first_run)
|
||||
+ {
|
||||
+ if(fuzzer_first_run)
|
||||
+ {
|
||||
+#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
||||
+
|
||||
/* Initialize startup process environment if necessary. */
|
||||
if (!IsUnderPostmaster)
|
||||
InitStandaloneProcess(argv[0]);
|
||||
@@ -4271,6 +4285,11 @@ PostgresMain(int argc, char *argv[],
|
||||
AssertArg(dbname != NULL);
|
||||
AssertArg(username != NULL);
|
||||
|
||||
@@ -4312,6 +4325,11 @@ PostgresMain(const char *dbname, const char *username)
|
||||
if (!ignore_till_sync)
|
||||
send_ready_for_query = true; /* initially, or after error */
|
||||
|
||||
|
@ -54,7 +55,7 @@ index 825fd55107..f3e2dbbf20 100644
|
|||
* Non-error queries loop here.
|
||||
*/
|
||||
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
|
||||
index a1ebe06d5b..dfa94013a0 100644
|
||||
index 2af87ee3bd..825bb70532 100644
|
||||
--- a/src/backend/utils/error/elog.c
|
||||
+++ b/src/backend/utils/error/elog.c
|
||||
@@ -594,7 +594,9 @@ errfinish(const char *filename, int lineno, const char *funcname)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#
|
||||
################################################################################
|
||||
cp -r $SRC/fuzzer src/backend/
|
||||
git apply ../add_fuzzers.diff
|
||||
git apply --ignore-space-change --ignore-whitespace ../add_fuzzers.diff
|
||||
|
||||
useradd fuzzuser
|
||||
chown -R fuzzuser .
|
||||
|
@ -35,9 +35,12 @@ make clean
|
|||
make
|
||||
cd src/backend/fuzzer
|
||||
make fuzzer
|
||||
if [ "$FUZZING_ENGINE" = "afl" ]
|
||||
then
|
||||
rm protocol_fuzzer
|
||||
fi
|
||||
#if [ "$FUZZING_ENGINE" = "afl" ]
|
||||
#then
|
||||
rm protocol_fuzzer
|
||||
#fi
|
||||
cp *_fuzzer $OUT/
|
||||
cp $SRC/postgresql_fuzzer_seed_corpus.zip $OUT/
|
||||
|
||||
# Temporary fix. Todo: David fix this.
|
||||
#rm $OUT/protocol_fuzzer
|
||||
|
|
|
@ -74,7 +74,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) {
|
|||
MemoryContextInit();
|
||||
if(!sigsetjmp(postgre_exit, 0)){
|
||||
postgre_started = true;
|
||||
PostgresMain(5, av, "dbfuzz", "fuzzuser");
|
||||
PostgresSingleUserMain(5, av, "fuzzuser");
|
||||
}
|
||||
pq_endmsgread();
|
||||
return 0;
|
||||
|
@ -106,7 +106,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||
|
||||
if(!sigsetjmp(postgre_exit, 0)){
|
||||
postgre_started = true;
|
||||
PostgresMain(5, av, "dbfuzz", "fuzzuser");
|
||||
PostgresSingleUserMain(5, av, "fuzzuser");
|
||||
}
|
||||
pq_endmsgread();
|
||||
postgre_started = false;
|
||||
|
|
Loading…
Reference in New Issue