Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet don't assume alignment of sack options.



details:   https://anonhg.NetBSD.org/src/rev/2061f40db6a8
branches:  trunk
changeset: 574617:2061f40db6a8
user:      yamt <yamt%NetBSD.org@localhost>
date:      Sun Mar 06 23:05:56 2005 +0000

description:
don't assume alignment of sack options.

diffstat:

 sys/netinet/tcp_sack.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 5a8a31dbd2c6 -r 2061f40db6a8 sys/netinet/tcp_sack.c
--- a/sys/netinet/tcp_sack.c    Sun Mar 06 23:05:20 2005 +0000
+++ b/sys/netinet/tcp_sack.c    Sun Mar 06 23:05:56 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_sack.c,v 1.2 2005/03/06 23:05:20 yamt Exp $ */
+/* $NetBSD: tcp_sack.c,v 1.3 2005/03/06 23:05:56 yamt Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -109,7 +109,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_sack.c,v 1.2 2005/03/06 23:05:20 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_sack.c,v 1.3 2005/03/06 23:05:56 yamt Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -253,8 +253,10 @@
        num_sack_blks = optlen / 8;
        acked = (SEQ_GT(th->th_ack, tp->snd_una)) ? th->th_ack : tp->snd_una;
        for (i = 0; i < num_sack_blks; i++, lp += 2) {
-               left = ntohl(*lp);
-               right = ntohl(*(lp + 1));
+               memcpy(&left, lp, sizeof(*lp));
+               memcpy(&right, lp + 1, sizeof(*lp));
+               left = ntohl(left);
+               right = ntohl(right);
 
                if ((SEQ_LEQ(right, acked)) ||
                                SEQ_GEQ(left, tp->snd_max) ||



Home | Main Index | Thread Index | Old Index