aboutsummaryrefslogtreecommitdiffstats
path: root/main/postgresql/fix-psql-segfault.patch
diff options
context:
space:
mode:
authorMilan P. Stanić <mps@arvanta.net>2019-08-25 16:01:26 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2019-09-05 08:47:18 +0000
commit7c92c452f53a00bb0f1376f90c0a61a54a93d679 (patch)
tree04c44431600a93b27e77315583cd0949d83b5dfd /main/postgresql/fix-psql-segfault.patch
parent9246da48765ae11d9c23fd109369bbc3cc42e46a (diff)
downloadaports-7c92c452f53a00bb0f1376f90c0a61a54a93d679.tar.bz2
aports-7c92c452f53a00bb0f1376f90c0a61a54a93d679.tar.xz
main/postgresql: fix psql segmentation fault
psql segfaults when passing an argument option with a missing argument patch sent from Quentin Rameau <quinq@fifth.space> fixes it
Diffstat (limited to 'main/postgresql/fix-psql-segfault.patch')
-rw-r--r--main/postgresql/fix-psql-segfault.patch34
1 files changed, 34 insertions, 0 deletions
diff --git a/main/postgresql/fix-psql-segfault.patch b/main/postgresql/fix-psql-segfault.patch
new file mode 100644
index 0000000000..8f4cc7902c
--- /dev/null
+++ b/main/postgresql/fix-psql-segfault.patch
@@ -0,0 +1,34 @@
+From 9644da5c3ffcf0fb18eca54a61aedb5f53a1c352 Mon Sep 17 00:00:00 2001
+From: Quentin Rameau <quinq@fifth.space>
+Date: Sun, 25 Aug 2019 11:29:45 +0200
+Subject: [PATCH] Fix missing argument handling in psql getopt
+
+When passing an argument option with a missing argument, strcmp would
+be called with the argv terminating NULL.
+---
+ src/bin/psql/startup.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
+index 4730c73396..cffbfc864e 100644
+--- a/src/bin/psql/startup.c
++++ b/src/bin/psql/startup.c
+@@ -667,12 +667,13 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts *options)
+ break;
+ case '?':
+ /* Actual help option given */
+- if (strcmp(argv[optind - 1], "-?") == 0)
++ if (optind <= argc &&
++ strcmp(argv[optind - 1], "-?") == 0)
+ {
+ usage(NOPAGER);
+ exit(EXIT_SUCCESS);
+ }
+- /* unknown option reported by getopt */
++ /* unknown option or missing argument */
+ else
+ goto unknown_option;
+ break;
+--
+2.23.0
+