Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jul 2005 18:25:27 -0700
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        current@freebsd.org
Subject:   another dhclient patch
Message-ID:  <20050728012527.GA23648@odin.ac.hmc.edu>

next in thread | raw e-mail | index | archive | help

--fUYQa+Pmc3FrFX/N
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Here's another dhclient patch to address another bug in the bpf code
by correctly using BPF_WORDALIGN to advance the pointer.  It assumes
the previous patch (as committed to HEAD) has been applied.  I've got a
couple systems running this with debug compiled versons so if we still
have bpf related bugs, I should be able to find them.

-- Brooks

----- Forwarded message from Brooks Davis <brooks@freebsd.org> -----

From: Brooks Davis <brooks@freebsd.org>
Date: Thu, 28 Jul 2005 01:18:21 GMT
To: Perforce Change Reviews <perforce@freebsd.org>
Subject: PERFORCE change 81096 for review

http://perforce.freebsd.org/chv.cgi?CH=3D81096

Change 81096 by brooks@brooks_pagefault on 2005/07/28 01:17:44

	Futher BPF handing fixes.  Use BPF_WORDALIGN when incrementing
	the pointer.  From ISC via krw at OpenBSD.

Affected files ...

=2E. //depot/user/brooks/cleanup/sbin/dhclient/bpf.c#6 edit

Differences ...

=3D=3D=3D=3D //depot/user/brooks/cleanup/sbin/dhclient/bpf.c#6 (text+ko) =
=3D=3D=3D=3D

@@ -325,7 +325,9 @@
 		 * do is drop it.
 		 */
 		if (hdr.bh_caplen !=3D hdr.bh_datalen) {
-			interface->rbuf_offset +=3D hdr.bh_caplen;
+			interface->rbuf_offset =3D
+			    BPF_WORDALIGN(interface->rbuf_offset +
+			    hdr.bh_caplen);
 			continue;
 		}
=20
@@ -339,7 +341,9 @@
 		 * this packet.
 		 */
 		if (offset < 0) {
-			interface->rbuf_offset +=3D hdr.bh_caplen;
+			interface->rbuf_offset =3D
+			    BPF_WORDALIGN(interface->rbuf_offset +
+			    hdr.bh_caplen);
 			continue;
 		}
 		interface->rbuf_offset +=3D offset;
@@ -351,7 +355,9 @@
=20
 		/* If the IP or UDP checksum was bad, skip the packet... */
 		if (offset < 0) {
-			interface->rbuf_offset +=3D hdr.bh_caplen;
+			interface->rbuf_offset =3D
+			    BPF_WORDALIGN(interface->rbuf_offset +
+			    hdr.bh_caplen);
 			continue;
 		}
 		interface->rbuf_offset +=3D offset;
@@ -363,14 +369,18 @@
 		 * life, though).
 		 */
 		if (hdr.bh_caplen > len) {
-			interface->rbuf_offset +=3D hdr.bh_caplen;
+			interface->rbuf_offset =3D
+			    BPF_WORDALIGN(interface->rbuf_offset +
+			    hdr.bh_caplen);
 			continue;
 		}
=20
 		/* Copy out the data in the packet... */
 		memcpy(buf, interface->rbuf + interface->rbuf_offset,
 		    hdr.bh_caplen);
-		interface->rbuf_offset +=3D hdr.bh_caplen;
+		interface->rbuf_offset =3D
+		    BPF_WORDALIGN(interface->rbuf_offset +
+		    hdr.bh_caplen);
 		return (hdr.bh_caplen);
 	} while (!length);
 	return (0);

----- End forwarded message -----
--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--fUYQa+Pmc3FrFX/N
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFC6DQHXY6L6fI4GtQRAmvaAJ0ZZYRJVQyWnvdLeqww/yPtp4WXRgCgqpZp
PSfL59+SEGCJDj3IOEjv9Es=
=l15E
-----END PGP SIGNATURE-----

--fUYQa+Pmc3FrFX/N--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050728012527.GA23648>