Commit bf5c5edc authored by Milan P. Stanić's avatar Milan P. Stanić

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
parent 7e9a5211
Pipeline #235 passed with stage
in 27 seconds
......@@ -3,7 +3,7 @@
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
pkgname=postgresql
pkgver=11.5
pkgrel=0
pkgrel=1
pkgdesc="A sophisticated object-relational DBMS"
url="https://www.postgresql.org/"
arch="all"
......@@ -26,6 +26,7 @@ source="https://ftp.postgresql.org/pub/source/v$pkgver/$pkgname-$pkgver.tar.bz2
perl-rpath.patch
conf-unix_socket_directories.patch
disable-broken-tests.patch
fix-psql-segfault.patch
$pkgname.initd
$pkgname.confd
pg-restore.initd
......@@ -312,6 +313,7 @@ sha512sums="537148079dc6c33cfb9bf9722171e524707b42ef01369deb968d0d6e8fa9b7f16f6c
5f9d8bb4957194069d01af8ab3abc6d4d83a7e7f8bd7ebe1caae5361d621a3e58f91b14b952958138a794e0a80bc154fbb7e3e78d211e2a95b9b7901335de854 perl-rpath.patch
8439a6fdfdea0a4867daeb8bc23d6c825f30c00d91d4c39f48653f5ee77341f23282ce03a77aad94b5369700f11d2cb28d5aee360e59138352a9ab331a9f9d0f conf-unix_socket_directories.patch
274e0a5a6e7d179f5327ae2da0274f13d9198d9acbe45f90e2bdadf454f1e32aceac6a1d4ef2b1744c4468994e93b14a38abea877b419b3fd28b8a3273b5d574 disable-broken-tests.patch
4a241074d27d638743eb56eedbc3cefe5ed4c02b6bf8030940be960d8c09ef88751443162ab405853d8db9ecc4af08ddb250096464d89cae5c0d4d4bf7eeb51f fix-psql-segfault.patch
224e80f9e62843fd248e625abdd0d9fe477729ff3f9a64fc5c86dd37bb7176d3504107fbed7ce578e3a1db7f60b8cf2abf5fe4862c81f76b6d026e29ca495cfc postgresql.initd
a6d9cba5c7270484b3a22083b2b37742faefb01b6643040050c92235840c601b2e206ebda32804937b729c6cf42c79a558b921900e52fc420df2a03b5f29e1f7 postgresql.confd
f5a1cba051e7d846c2d16703514601cb25729ed96b677c9bd0c199d64552120a8b14b238af01917fdb87106681e12dee6fff7447558155ba273e4f96be5e2892 pg-restore.initd
......
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment