Skip to content

Commit

Permalink
net: packet socket packet_lookup_frame fix
Browse files Browse the repository at this point in the history
packet_lookup_frames() fails to get user frame if current frame header
status contains extra flags.
This is due to the wrong assumption on the operators precedence during
frame status tests.
Fixed by forcing the right operators precedence order with explicit brackets.

Signed-off-by: Paolo Abeni <paolo.abeni@gmail.com>
Signed-off-by: Sebastiano Di Paola <sebastiano.dipaola@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sebastiano Di Paola authored and David S. Miller committed Feb 1, 2009
1 parent 5d0932a commit f9e6934
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ static void *packet_lookup_frame(struct packet_sock *po, unsigned int position,
h.raw = po->pg_vec[pg_vec_pos] + (frame_offset * po->frame_size);
switch (po->tp_version) {
case TPACKET_V1:
if (status != h.h1->tp_status ? TP_STATUS_USER :
TP_STATUS_KERNEL)
if (status != (h.h1->tp_status ? TP_STATUS_USER :
TP_STATUS_KERNEL))
return NULL;
break;
case TPACKET_V2:
if (status != h.h2->tp_status ? TP_STATUS_USER :
TP_STATUS_KERNEL)
if (status != (h.h2->tp_status ? TP_STATUS_USER :
TP_STATUS_KERNEL))
return NULL;
break;
}
Expand Down

0 comments on commit f9e6934

Please sign in to comment.