diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2001-07-16 22:43:20 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2001-07-16 22:43:20 +0000 |
commit | 6c80174ecf1dceb7bc8e2a78602e150e6b72ce77 (patch) | |
tree | 2e865e840aaf36d597774f8e25536eef81d46cc6 /sbin/pfctl | |
parent | 8ce7b3127641adf107649cff8c56d6a573b15617 (diff) |
errx() if getservbyname() fails
Diffstat (limited to 'sbin/pfctl')
-rw-r--r-- | sbin/pfctl/parse.y | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 20db6f327f6..c303503abda 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.2 2001/07/16 22:09:55 markus Exp $ */ +/* $OpenBSD: parse.y,v 1.3 2001/07/16 22:43:19 markus Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -282,10 +282,16 @@ port: NUMBER { $$ = htons($1); } struct servent *s = NULL; /* use synthesysed attribute */ - if (proto) + if (proto) { s = getservbyname($1, proto == IPPROTO_TCP ? "tcp" : "udp"); - $$ = (s == NULL) ? 0 : s->s_port; + if (s == NULL) + errx(1, "line %d: unknown protocol %s", + lineno, $1); + $$ = s->s_port; + } else { + $$ = 0; + } } ; |