Skip to content

Commit

Permalink
[NETFILTER] arp_tables: Fix unaligned accesses.
Browse files Browse the repository at this point in the history
There are two device string comparison loops in arp_packet_match().
The first one goes byte-by-byte but the second one tries to be
clever and cast the string to a long and compare by longs.

The device name strings in the arp table entries are not guarenteed
to be aligned enough to make this value, so just use byte-by-byte
for both cases.

Based upon a report by <drraid@gmail.com>.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Apr 13, 2007
1 parent 612f09e commit 49688c8
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions net/ipv4/netfilter/arp_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,9 @@ static inline int arp_packet_match(const struct arphdr *arphdr,
return 0;
}

for (i = 0, ret = 0; i < IFNAMSIZ/sizeof(unsigned long); i++) {
unsigned long odev;
memcpy(&odev, outdev + i*sizeof(unsigned long),
sizeof(unsigned long));
ret |= (odev
^ ((const unsigned long *)arpinfo->outiface)[i])
& ((const unsigned long *)arpinfo->outiface_mask)[i];
for (i = 0, ret = 0; i < IFNAMSIZ; i++) {
ret |= (outdev[i] ^ arpinfo->outiface[i])
& arpinfo->outiface_mask[i];
}

if (FWINV(ret != 0, ARPT_INV_VIA_OUT)) {
Expand Down

0 comments on commit 49688c8

Please sign in to comment.