mirror of https://github.com/google/oss-fuzz.git
69 lines
2.0 KiB
Diff
69 lines
2.0 KiB
Diff
|
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
|
||
|
index c9424f167c..aa2897ec63 100644
|
||
|
--- a/src/backend/tcop/postgres.c
|
||
|
+++ b/src/backend/tcop/postgres.c
|
||
|
@@ -101,6 +101,10 @@ int max_stack_depth = 100;
|
||
|
/* wait N seconds to allow attach from a debugger */
|
||
|
int PostAuthDelay = 0;
|
||
|
|
||
|
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||
|
+bool fuzzer_first_run = true;
|
||
|
+#endif
|
||
|
+
|
||
|
|
||
|
|
||
|
/* ----------------
|
||
|
@@ -505,11 +509,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;
|
||
|
}
|
||
|
|
||
|
@@ -3784,6 +3791,10 @@ PostgresMain(int argc, char *argv[],
|
||
|
volatile bool send_ready_for_query = true;
|
||
|
bool disable_idle_in_transaction_timeout = false;
|
||
|
|
||
|
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||
|
+ if(fuzzer_first_run)
|
||
|
+ {
|
||
|
+#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
||
|
/* Initialize startup process environment if necessary. */
|
||
|
if (!IsUnderPostmaster)
|
||
|
InitStandaloneProcess(argv[0]);
|
||
|
@@ -4151,6 +4162,11 @@ PostgresMain(int argc, char *argv[],
|
||
|
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 d0b368530e..02a3e9066e 100644
|
||
|
--- a/src/backend/utils/error/elog.c
|
||
|
+++ b/src/backend/utils/error/elog.c
|
||
|
@@ -513,7 +513,9 @@ errfinish(const char *filename, int lineno, const char *funcname)
|
||
|
pq_endcopyout(true);
|
||
|
|
||
|
/* 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)
|