Skip to content

Commit bf53d5c

Browse files
committed
Teach the configure script to validate its --with-pgport argument.
Previously, configure would take any string, including an empty string, leading to obscure compile failures in guc.c. It seems worth expending a few lines of code to ensure that the argument is a decimal number between 1 and 65535. Report and patch by Jim Nasby; reviews by Alex Shulgin, Peter Eisentraut, Ivan Kartyshov
1 parent 9da70ef commit bf53d5c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

configure

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,6 +3100,17 @@ _ACEOF
31003100

31013101

31023102

3103+
# It's worth validating port; you can get very confusing errors otherwise
3104+
if test x"$default_port" = x""; then
3105+
as_fn_error $? "invalid --with-pgport specification: empty string" "$LINENO" 5
3106+
elif test ! x`echo "$default_port" | sed -e 's/[0-9]*//'` = x""; then
3107+
as_fn_error $? "invalid --with-pgport specification: must be a number" "$LINENO" 5
3108+
elif test ! x`echo "$default_port" | sed -e 's/^0.//'` = x"$default_port"; then
3109+
as_fn_error $? "invalid --with-pgport specification: must not have leading 0" "$LINENO" 5
3110+
elif test "$default_port" -lt "1" -o "$default_port" -gt "65535"; then
3111+
as_fn_error $? "invalid --with-pgport specification: must be between 1 and 65535" "$LINENO" 5
3112+
fi
3113+
31033114
#
31043115
# '-rpath'-like feature can be disabled
31053116
#

configure.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}",
165165
[Define to the default TCP port number as a string constant.])
166166
AC_SUBST(default_port)
167167

168+
# It's worth validating port; you can get very confusing errors otherwise
169+
if test x"$default_port" = x""; then
170+
AC_MSG_ERROR([invalid --with-pgport specification: empty string])
171+
elif test ! x`echo "$default_port" | sed -e 's/[[0-9]]*//'` = x""; then
172+
AC_MSG_ERROR([invalid --with-pgport specification: must be a number])
173+
elif test ! x`echo "$default_port" | sed -e 's/^0.//'` = x"$default_port"; then
174+
AC_MSG_ERROR([invalid --with-pgport specification: must not have leading 0])
175+
elif test "$default_port" -lt "1" -o "$default_port" -gt "65535"; then
176+
AC_MSG_ERROR([invalid --with-pgport specification: must be between 1 and 65535])
177+
fi
178+
168179
#
169180
# '-rpath'-like feature can be disabled
170181
#

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy