[Click] [PATCH] Don't ignore return values in wifi elements

Eddie Kohler kohler at cs.ucla.edu
Wed Mar 11 11:32:13 EDT 2009


Thanks, applied!  Here is my checkin message, FYI:

     Eddie's note: These elements still have many issues -- for example,
     WifiDefrag never cleans up its table, and contains assertions about nfo->p
     not being null that may be violated if fragments arrive out of order or a
     put() attempt fails.  If you depend on these elements you should really
     consider giving them some care & feeding.

Eddie


roberto.riggio at create-net.org wrote:
> Don't ignore return values in wifi elements.
> 
> --
> 
> diff --git a/elements/wifi/wepencap.cc b/elements/wifi/wepencap.cc
> index c34c728..461c229 100644
> --- a/elements/wifi/wepencap.cc
> +++ b/elements/wifi/wepencap.cc
> @@ -102,7 +102,8 @@ WepEncap::simple_action(Packet *p_in)
>    }
>    w->i_fc[1] |= WIFI_FC1_WEP;
>  
> -  p->push(WIFI_WEP_HEADERSIZE);
> +  if (!(p = p->push(WIFI_WEP_HEADERSIZE)))
> +    return 0;
>    memmove((void *) p->data(), p->data() + WIFI_WEP_HEADERSIZE, sizeof(click_wifi));
>    u_int8_t *ivp = p->data() + sizeof(click_wifi);
>    u_int32_t iv = click_random()  & 0xffffff;
> diff --git a/elements/wifi/wifidefrag.cc b/elements/wifi/wifidefrag.cc
> index eca17e1..635d1c6 100644
> --- a/elements/wifi/wifidefrag.cc
> +++ b/elements/wifi/wifidefrag.cc
> @@ -120,7 +120,8 @@ WifiDefrag::simple_action(Packet *p)
>      uint32_t len = nfo->p->length();
>  
>      p->pull(sizeof(click_wifi));
> -    nfo->p->put(p->length());
> +    if (!(nfo->p = nfo->p->put(p->length())))
> +      return 0;
>      memcpy((void *) (nfo->p->data() + len), p->data(), p->length());
>      p->kill();
>    }
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click


More information about the click mailing list