diff options
author | bluhm <bluhm@openbsd.org> | 2011-09-20 15:17:26 +0000 |
---|---|---|
committer | bluhm <bluhm@openbsd.org> | 2011-09-20 15:17:26 +0000 |
commit | fb75e2fc14979f5b774b62725ae6bc2acfe75268 (patch) | |
tree | 16fe05656c68df4a73367149eccc20ed5395daad /sys/net/pf_osfp.c | |
parent | use a pexp here too; noted by MERIGHI Marcus <mcmer-openbsd@tor.at> (diff) | |
download | wireguard-openbsd-fb75e2fc14979f5b774b62725ae6bc2acfe75268.tar.xz wireguard-openbsd-fb75e2fc14979f5b774b62725ae6bc2acfe75268.zip |
pf_setup_pdesc() panics if address family is neither AF_INET nor
AF_INET6. So remove useless af switch defaults here and there.
Always use "switch(af)" instead of "if (af) else" for af dependent
code. Always use AF_ defines instead of PF_ when checking af values.
ok claudio mpf henning
Diffstat (limited to 'sys/net/pf_osfp.c')
-rw-r--r-- | sys/net/pf_osfp.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/net/pf_osfp.c b/sys/net/pf_osfp.c index 7f934a88285..21d49b523e9 100644 --- a/sys/net/pf_osfp.c +++ b/sys/net/pf_osfp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_osfp.c,v 1.22 2011/09/19 12:51:52 bluhm Exp $ */ +/* $OpenBSD: pf_osfp.c,v 1.23 2011/09/20 15:17:26 bluhm Exp $ */ /* * Copyright (c) 2003 Mike Frantzen <frantzen@w4g.org> @@ -85,20 +85,20 @@ struct pf_osfp_enlist * pf_osfp_fingerprint(struct pf_pdesc *pd, struct mbuf *m) { struct tcphdr *th = pd->hdr.tcp; - struct ip *ip; - struct ip6_hdr *ip6; - char hdr[60]; + struct ip *ip = NULL; + struct ip6_hdr *ip6 = NULL; + char hdr[60]; - if ((pd->af != PF_INET && pd->af != PF_INET6) || - pd->proto != IPPROTO_TCP || (th->th_off << 2) < sizeof(*th)) + if (pd->proto != IPPROTO_TCP || (th->th_off << 2) < sizeof(*th)) return (NULL); - if (pd->af == PF_INET) { + switch (pd->af) { + case AF_INET: ip = mtod(m, struct ip *); - ip6 = (struct ip6_hdr *)NULL; - } else { - ip = (struct ip *)NULL; + break; + case AF_INET6: ip6 = mtod(m, struct ip6_hdr *); + break; } if (!pf_pull_hdr(m, pd->off, hdr, th->th_off << 2, NULL, NULL, pd->af)) return (NULL); |