summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authortracey <tracey@cvs.openbsd.org>2020-08-25 13:50:41 +0000
committertracey <tracey@cvs.openbsd.org>2020-08-25 13:50:41 +0000
commit69e4e3eb11ef105339927f662723072f7d7e565e (patch)
tree45fbb1c823e145d890d8e0dfec4afab365fd9d33 /usr.sbin
parent158072d60618b37d1a180094cc8bde54959e1335 (diff)
check that fcgiport string value is within range
remove redundant error message tweaks and ok florian@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/httpd/parse.y16
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y
index f9a73fe1041..0103002b342 100644
--- a/usr.sbin/httpd/parse.y
+++ b/usr.sbin/httpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.115 2020/08/24 15:49:11 tracey Exp $ */
+/* $OpenBSD: parse.y,v 1.116 2020/08/25 13:50:40 tracey Exp $ */
/*
* Copyright (c) 2007 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -1123,7 +1123,15 @@ fcgiport : NUMBER {
YYERROR;
}
}
- | STRING { $$ = $1; }
+ | STRING {
+ if (getservice($1) <= 0) {
+ yyerror("invalid port: %s", $1);
+ free($1);
+ YYERROR;
+ }
+
+ $$ = $1;
+ }
;
tcpip : TCP '{' optnl tcpflags_l '}'
@@ -2366,10 +2374,8 @@ getservice(char *n)
s = getservbyname(n, "tcp");
if (s == NULL)
s = getservbyname(n, "udp");
- if (s == NULL) {
- yyerror("unknown port %s", n);
+ if (s == NULL)
return (-1);
- }
return (s->s_port);
}