summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2010-07-08 19:30:17 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2010-07-08 19:30:17 +0000
commit7524ee837cf2d945ff4fbee9639a0992db5150e3 (patch)
tree5dec1fbc706b709fcfff309d48c4523917026f66
parenta79365931e84b710ebd13303a5b7478f4c56b760 (diff)
Use correct alignment for scrub max-mss. Based on a diff from deraadt.
"that looks about right even though the offset calculation is pure horror" claudio@, ok deraadt@
-rw-r--r--sys/net/pf_norm.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/net/pf_norm.c b/sys/net/pf_norm.c
index 1c46a4b2da5..c382deb2162 100644
--- a/sys/net/pf_norm.c
+++ b/sys/net/pf_norm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_norm.c,v 1.122 2010/07/02 02:40:16 blambert Exp $ */
+/* $OpenBSD: pf_norm.c,v 1.123 2010/07/08 19:30:16 sthen Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@@ -1323,7 +1323,7 @@ int
pf_normalize_mss(struct mbuf *m, int off, struct pf_pdesc *pd, u_int16_t maxmss)
{
struct tcphdr *th = pd->hdr.tcp;
- u_int16_t *mss;
+ u_int16_t mss;
int thoff;
int opt, cnt, optlen = 0;
u_char opts[MAX_TCPOPTLEN];
@@ -1351,13 +1351,14 @@ pf_normalize_mss(struct mbuf *m, int off, struct pf_pdesc *pd, u_int16_t maxmss)
}
switch (opt) {
case TCPOPT_MAXSEG:
- mss = (u_int16_t *)(optp + 2);
- if ((ntohs(*mss)) > maxmss) {
+ bcopy((caddr_t)(optp + 2), (caddr_t)&mss, 2);
+ if (ntohs(mss) > maxmss) {
th->th_sum = pf_cksum_fixup(th->th_sum,
- *mss, htons(maxmss), 0);
- *mss = htons(maxmss);
- m_copyback(m, off + sizeof(*th),
- thoff - sizeof(*th), opts, M_NOWAIT);
+ mss, htons(maxmss), 0);
+ mss = htons(maxmss);
+ m_copyback(m,
+ off + sizeof(*th) + optp + 2 - opts,
+ 2, &mss, M_NOWAIT);
m_copyback(m, off, sizeof(*th), th, M_NOWAIT);
}
break;