Patch: minor nit in ip_options_compile()
Subsystems (3)
In the following else clause, we check for opt->is_data, which should always be set for this case, and if not, current code will lead to a null ptr dereference because skb is always null in this case..
Figured its better to fall down to returning EINVAL.. Look reasonable?
thanks,
Nivedita
usr/src/linux-2.5.65ref1/net/ipv4/ip_options.c renamed from usr/src/linux-2.5.65/net/ipv4/ip_options.c +4 -2
@@ -245,7 +245,7 @@int ip_options_compile (struct ip_options * opt,struct sk_buff * skb) {int l; -unsigned char * iph; +unsigned char * iph =NULL ;unsigned char * optptr;int optlen;unsigned char * pp_ptr =NULL ;
@@ -259,7 +259,9 @@ optptr = iph +sizeof (struct iphdr ); opt->is_data =0 ; }else { - optptr = opt->is_data ? opt->__data : (unsigned char *)&(skb->nh.iph[1 ]); +/* Only caller here is ip_options_get(), sets up opt, no skb */ +if ((optptr = opt->__data) ==0 ) + goto error; iph = optptr -sizeof (struct iphdr ); }
Hello!
Quoted 4 lines
In the following else clause, we check for
opt->is_data, which=20 should always be set for this case, and if not, current code will lead to a null ptr dereference because skb is always null in=20 this case..
You misunderstood tha code. If opt->is_data is clear skb may be not NULL. The option is not used at the moment, but it it pretty silly to lose this.
Quoted 1 line
Look reasonable?=20
No:
Quoted 2 lines
+=09=09if ((optptr =3D opt->__data) =3D=3D 0) +=09=09=09goto error;=20
is identical FALSE. [Sent quatable-printable attachment? Get it back quoted. :-)]
Quoted 1 line
Figured its better to fall down to returning EINVAL..
if (skb == NULL)
BUG();
Listen, I love to add BUG()s when it is not mathematically clear that something is invariant. Not in this trivial case.
Alexey