summaryrefslogtreecommitdiff
path: root/sbin/pfctl
diff options
context:
space:
mode:
authorCamiel Dobbelaar <camield@cvs.openbsd.org>2003-01-19 15:28:13 +0000
committerCamiel Dobbelaar <camield@cvs.openbsd.org>2003-01-19 15:28:13 +0000
commitc2f8bf44858c953d1576bf46f5162f6ade9d8687 (patch)
tree69fb4eb83762a41aa86d5230bed4b71ae722dee2 /sbin/pfctl
parent4313458ad98a8314c696b5100ea7cccd2b0923b3 (diff)
Simplify and KNF anchoropt processing.
ok dhartmei henning
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/pfctl.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index f027b3b2046..8239818d9ec 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl.c,v 1.136 2003/01/19 13:48:06 dhartmei Exp $ */
+/* $OpenBSD: pfctl.c,v 1.137 2003/01/19 15:28:12 camield Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -1378,9 +1378,9 @@ main(int argc, char *argv[])
memset(anchorname, 0, sizeof(anchorname));
memset(rulesetname, 0, sizeof(rulesetname));
if (anchoropt != NULL) {
- char *t = strchr(anchoropt, ':');
+ char *t;
- if (t == NULL) {
+ if ((t = strchr(anchoropt, ':')) == NULL) {
if (strlcpy(anchorname, anchoropt,
sizeof(anchorname)) >= sizeof(anchorname))
errx(1, "anchor name '%s' too long",
@@ -1388,21 +1388,18 @@ main(int argc, char *argv[])
} else {
char *p;
- if (t == anchoropt || !strlen(t+1))
- errx(1, "anchor names '%s' invalid", anchoropt);
- if ((p = malloc(strlen(anchoropt) + 1)) == NULL)
- err(1, "malloc");
- strlcpy(p, anchoropt, strlen(anchoropt) + 1);
- if ((t = strsep(&p, ":")) == NULL)
- errx(1, "anchor names '%s' invalid",
- anchoropt);
+ if ((p = strdup(anchoropt)) == NULL)
+ err(1, "anchoropt: strdup");
+ t = strsep(&p, ":");
+ if (*t == '\0' || *p == '\0')
+ errx(1, "anchor '%s' invalid", anchoropt);
if (strlcpy(anchorname, t, sizeof(anchorname)) >=
sizeof(anchorname))
errx(1, "anchor name '%s' too long", t);
if (strlcpy(rulesetname, p, sizeof(rulesetname)) >=
sizeof(rulesetname))
errx(1, "ruleset name '%s' too long", p);
- free(t);
+ free(t); /* not p */
}
}