2020-09-17 04:42:31 +00:00
|
|
|
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
|
2021-04-15 11:48:02 +00:00
|
|
|
index 825fd55107..f3e2dbbf20 100644
|
2020-09-17 04:42:31 +00:00
|
|
|
--- a/src/backend/tcop/postgres.c
|
|
|
|
+++ b/src/backend/tcop/postgres.c
|
2021-04-15 11:48:02 +00:00
|
|
|
@@ -105,6 +105,10 @@ int PostAuthDelay = 0;
|
|
|
|
/* Time between checks that the client is still connected. */
|
|
|
|
int client_connection_check_interval = 0;
|
2020-09-17 04:42:31 +00:00
|
|
|
|
|
|
|
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
|
|
+bool fuzzer_first_run = true;
|
|
|
|
+#endif
|
2021-04-15 11:48:02 +00:00
|
|
|
+
|
2020-09-17 04:42:31 +00:00
|
|
|
/* ----------------
|
2021-04-15 11:48:02 +00:00
|
|
|
* private typedefs etc
|
|
|
|
* ----------------
|
|
|
|
@@ -454,10 +458,15 @@ ReadCommand(StringInfo inBuf)
|
2020-09-17 04:42:31 +00:00
|
|
|
{
|
|
|
|
int result;
|
2021-02-22 00:07:01 +00:00
|
|
|
|
2020-09-17 04:42:31 +00:00
|
|
|
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
2021-02-22 00:07:01 +00:00
|
|
|
+ result = SocketBackend(inBuf);
|
2020-09-17 04:42:31 +00:00
|
|
|
+#else
|
2021-02-22 00:07:01 +00:00
|
|
|
+
|
2020-09-17 04:42:31 +00:00
|
|
|
if (whereToSendOutput == DestRemote)
|
|
|
|
result = SocketBackend(inBuf);
|
|
|
|
else
|
|
|
|
result = InteractiveBackend(inBuf);
|
|
|
|
+#endif
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-04-15 11:48:02 +00:00
|
|
|
@@ -3910,6 +3919,11 @@ PostgresMain(int argc, char *argv[],
|
2021-02-22 00:07:01 +00:00
|
|
|
bool idle_in_transaction_timeout_enabled = false;
|
|
|
|
bool idle_session_timeout_enabled = false;
|
2020-09-17 04:42:31 +00:00
|
|
|
|
|
|
|
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
2021-02-22 00:07:01 +00:00
|
|
|
+ if(fuzzer_first_run)
|
|
|
|
+ {
|
2020-09-17 04:42:31 +00:00
|
|
|
+#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
2021-02-22 00:07:01 +00:00
|
|
|
+
|
2020-09-17 04:42:31 +00:00
|
|
|
/* Initialize startup process environment if necessary. */
|
|
|
|
if (!IsUnderPostmaster)
|
|
|
|
InitStandaloneProcess(argv[0]);
|
2021-04-15 11:48:02 +00:00
|
|
|
@@ -4271,6 +4285,11 @@ PostgresMain(int argc, char *argv[],
|
2020-09-17 04:42:31 +00:00
|
|
|
if (!ignore_till_sync)
|
|
|
|
send_ready_for_query = true; /* initially, or after error */
|
|
|
|
|
|
|
|
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
2021-02-22 00:07:01 +00:00
|
|
|
+ fuzzer_first_run=false;
|
|
|
|
+ }
|
2020-09-17 04:42:31 +00:00
|
|
|
+#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
|
2021-04-15 11:48:02 +00:00
|
|
|
index a1ebe06d5b..dfa94013a0 100644
|
2020-09-17 04:42:31 +00:00
|
|
|
--- a/src/backend/utils/error/elog.c
|
|
|
|
+++ b/src/backend/utils/error/elog.c
|
2021-04-15 11:48:02 +00:00
|
|
|
@@ -594,7 +594,9 @@ errfinish(const char *filename, int lineno, const char *funcname)
|
|
|
|
}
|
2020-09-17 04:42:31 +00:00
|
|
|
|
|
|
|
/* 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)
|