Skip to contentSkip to conversation

batman-adv: properly check pskb_may_pull return value

PATCH Applied Antonio Quartulli 2 participants 3 messages Jan 29, 2014 – Feb 2, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batman-adv: properly check pskb_may_pull return value

pskb_may_pull() returns 1 on success and 0 in case of failure, therefore checking for the return value being negative does not make sense at all.

Fix this by doing the proper check.

---
 routing.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
routing.c +1 -1
index f28920f..f7579d0 100644
@@ -833,7 +833,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
 	int is_old_ttvn;
 
 	/* check if there is enough data before accessing it */
-	if (pskb_may_pull(skb, hdr_len + ETH_HLEN) < 0)
+	if (!pskb_may_pull(skb, hdr_len + ETH_HLEN))
 		return 0;
 
 	/* create a copy of the skb (in case of for re-routing) to modify it. */
Signature · 1 line
1.8.5.3
#1 lore raw
Quoted 4 lines · Antonio Quartulli

pskb_may_pull() returns 1 on success and 0 in case of failure, therefore checking for the return value being negative does not make sense at all.

I should have added:

This way if the function fails we will probably read beyond the current skb data buffer.

Quoted 3 lines

Fix this by doing the proper check.

Signature · 1 line
Antonio Quartulli
#2 lore raw
Quoted 11 lines · On Thursday 30 January 2014 00:15:10 Antonio Quartulli wrote:
Quoted 5 lines · Antonio Quartulli

pskb_may_pull() returns 1 on success and 0 in case of failure, therefore checking for the return value being negative does not make sense at all.

I should have added:

This way if the function fails we will probably read beyond the current skb data buffer.

Applied in revision eabdc31.

Thanks,
Marek