diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2010-09-21 22:49:15 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2010-09-21 22:49:15 +0000 |
commit | dca748b1b3cbbb848daf0fe53d6efce0f92cb0a8 (patch) | |
tree | f1324605222e1831b27dca13230839043b6e7931 /sys/net/if_pflog.c | |
parent | 7e083e7d1f3ed272a595c2fcf389689e668c0d5c (diff) |
Don't dereference null pointers for protocols without port numbers.
From henning@, fixed pflog_bgpcopy crashes.
Diffstat (limited to 'sys/net/if_pflog.c')
-rw-r--r-- | sys/net/if_pflog.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/net/if_pflog.c b/sys/net/if_pflog.c index cc2e698d768..925fa67c660 100644 --- a/sys/net/if_pflog.c +++ b/sys/net/if_pflog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pflog.c,v 1.31 2010/09/21 11:29:12 henning Exp $ */ +/* $OpenBSD: if_pflog.c,v 1.32 2010/09/21 22:49:14 sthen Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -288,7 +288,7 @@ pflog_bpfcopy(const void *src_arg, void *dst_arg, size_t len) struct pf_pdesc pd; struct pf_addr osaddr, odaddr; - u_int16_t osport, odport; + u_int16_t osport = 0, odport = 0; m = src_arg; dst = dst_arg; @@ -340,8 +340,10 @@ pflog_bpfcopy(const void *src_arg, void *dst_arg, size_t len) PF_ACPY(&osaddr, pd.src, pd.af); PF_ACPY(&odaddr, pd.dst, pd.af); - osport = *pd.sport; - odport = *pd.dport; + if (pd.sport) + osport = *pd.sport; + if (pd.dport) + odport = *pd.dport; if ((pfloghdr->rewritten = pf_translate(&pd, &pfloghdr->saddr, pfloghdr->sport, &pfloghdr->daddr, pfloghdr->dport, 0, |