mirror of https://github.com/google/oss-fuzz.git
71 lines
2.0 KiB
Diff
71 lines
2.0 KiB
Diff
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
|
|
index 0775abe35d..f53b3580b3 100644
|
|
--- a/src/backend/tcop/postgres.c
|
|
+++ b/src/backend/tcop/postgres.c
|
|
@@ -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
|
|
* ----------------
|
|
@@ -471,11 +476,14 @@ static int
|
|
ReadCommand(StringInfo inBuf)
|
|
{
|
|
int result;
|
|
-
|
|
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
+ result = SocketBackend(inBuf);
|
|
+#else
|
|
if (whereToSendOutput == DestRemote)
|
|
result = SocketBackend(inBuf);
|
|
else
|
|
result = InteractiveBackend(inBuf);
|
|
+#endif
|
|
return result;
|
|
}
|
|
|
|
@@ -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)
|
|
+ {
|
|
+#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
|
+
|
|
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 */
|
|
|
|
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
+ fuzzer_first_run=false;
|
|
+ }
|
|
+#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
|
+
|
|
/*
|
|
* Non-error queries loop here.
|
|
*/
|
|
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
|
|
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)
|
|
}
|
|
|
|
/* Emit the message to the right places */
|
|
+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
EmitErrorReport();
|
|
+#endif
|
|
|
|
/* Now free up subsidiary data attached to stack entry, and release it */
|
|
if (edata->message)
|