aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar DavidKorczynski <david@adalogics.com>2021-02-22 00:07:01 +0000
committerGravatar GitHub <noreply@github.com>2021-02-21 16:07:01 -0800
commit2b4a1cdea5c5e525bf58fa49e4664ef051b19312 (patch)
tree7b3559339ded1149b282af5c5ddd15f6e4b41215
parentb793a4993427ff70e3f21b47352b1d37f310f91d (diff)
postgresql: fix fuzzers + build, and enable AFL. (#5164)
* postgresql: fix fuzzers and build, and enable AFL. * postgresql: fix up main repo. * postgresql: fix up the patch for postgresql.
-rw-r--r--projects/postgresql/add_fuzzers.diff34
-rw-r--r--projects/postgresql/fuzzer/simple_query_fuzzer.c2
-rw-r--r--projects/postgresql/project.yaml2
3 files changed, 20 insertions, 18 deletions
diff --git a/projects/postgresql/add_fuzzers.diff b/projects/postgresql/add_fuzzers.diff
index 2d3ce7b3..86b106c2 100644
--- a/projects/postgresql/add_fuzzers.diff
+++ b/projects/postgresql/add_fuzzers.diff
@@ -1,26 +1,25 @@
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
-index c9424f167c..aa2897ec63 100644
+index cb5a96117f..c9b4880085 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
-@@ -101,6 +101,10 @@ int max_stack_depth = 100;
+@@ -102,6 +102,9 @@ 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)
+@@ -507,10 +510,15 @@ 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,34 +28,35 @@ index c9424f167c..aa2897ec63 100644
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;
+@@ -3846,6 +3854,11 @@ PostgresMain(int argc, char *argv[],
+ 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]);
-@@ -4151,6 +4162,11 @@ PostgresMain(int argc, char *argv[],
+@@ -4207,6 +4220,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;
-+ }
++ 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
+index 80c2672461..c16e0423c5 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)
+@@ -600,7 +600,9 @@ errfinish(const char *filename, int lineno, const char *funcname)
pq_endcopyout(true);
/* Emit the message to the right places */
diff --git a/projects/postgresql/fuzzer/simple_query_fuzzer.c b/projects/postgresql/fuzzer/simple_query_fuzzer.c
index 3ba6b50e..29c13623 100644
--- a/projects/postgresql/fuzzer/simple_query_fuzzer.c
+++ b/projects/postgresql/fuzzer/simple_query_fuzzer.c
@@ -46,7 +46,7 @@ exec_simple_query(const char *query_string)
StartTransactionCommand();
oldcontext = MemoryContextSwitchTo(MessageContext);
- parsetree_list = raw_parser(query_string);
+ parsetree_list = raw_parser(query_string, RAW_PARSE_TYPE_NAME);
MemoryContextSwitchTo(oldcontext);
use_implicit_block = (list_length(parsetree_list) > 1);
diff --git a/projects/postgresql/project.yaml b/projects/postgresql/project.yaml
index 9517c603..5cc7a3ff 100644
--- a/projects/postgresql/project.yaml
+++ b/projects/postgresql/project.yaml
@@ -1,4 +1,5 @@
homepage: "https://postgresql.org"
+main_repo: "https://git.postgresql.org/git/postgresql"
primary_contact: "sfrost@snowman.net"
language: c
auto_ccs:
@@ -8,5 +9,6 @@ auto_ccs:
fuzzing_engines:
- libfuzzer
- honggfuzz
+ - afl
sanitizers:
- address