Commit 01e1f045e65b683fe7203b1e16a915bbb94c15fe

Authored by Daniel Drake
Committed by John W. Linville
1 parent a10605e599

ieee80211: fix unaligned access in ieee80211_copy_snap

There is no guarantee that data+SNAP_SIZE will reside on an even numbered
address, so doing a 16 bit read will cause an unaligned access in some
situations. Based on a patch from Jun Sun.

Signed-off-by: Daniel Drake <dsd@gentoo.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

net/ieee80211/ieee80211_tx.c
... ... @@ -144,7 +144,8 @@
144 144 snap->oui[1] = oui[1];
145 145 snap->oui[2] = oui[2];
146 146  
147   - *(u16 *) (data + SNAP_SIZE) = htons(h_proto);
  147 + h_proto = htons(h_proto);
  148 + memcpy(data + SNAP_SIZE, &h_proto, sizeof(u16));
148 149  
149 150 return SNAP_SIZE + sizeof(u16);
150 151 }