another dhclient patch

Brooks Davis brooks at one-eyed-alien.net
Thu Jul 28 01:25:29 GMT 2005


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 at freebsd.org> -----

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

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

Change 81096 by brooks at 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 ...

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

Differences ...

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

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

----- End forwarded message -----
-- 
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20050727/ec339451/attachment.bin


More information about the freebsd-current mailing list