Hi David,

On Fri, Jul 09, 2010 at 05:56:53PM +0100, David Woodhouse wrote:
> connman_wifi_load_ssid() can return NULL. Best not to dereference that.
Patch applied, although slightly differently.
I prefer to return when we get NULL from connman_wifi_load_ssid(), makes the
code more readable in my opinion.

Thanks for the fix.

Cheers,
Samuel.


> diff --git a/plugins/supplicant.c b/plugins/supplicant.c
> index 276fd91..34d72a0 100644
> --- a/plugins/supplicant.c
> +++ b/plugins/supplicant.c
> @@ -612,29 +612,30 @@ static void add_interface_reply(DBusPendingCall *call, 
> void *user_data)
>  
>       hex_ssids = connman_wifi_load_ssid();
>  
> -     for (i = 0; hex_ssids[i]; i++) {
> -             unsigned char *ssid;
> -             unsigned int j, k = 0, hex;
> -             size_t hex_ssid_len;
> +     if (hex_ssids) {
> +             for (i = 0; hex_ssids[i]; i++) {
> +                     unsigned char *ssid;
> +                     unsigned int j, k = 0, hex;
> +                     size_t hex_ssid_len;
>  
> -             hex_ssid = hex_ssids[i];
> -             hex_ssid_len = strlen(hex_ssid);
> +                     hex_ssid = hex_ssids[i];
> +                     hex_ssid_len = strlen(hex_ssid);
>  
> -             ssid = g_try_malloc0(hex_ssid_len / 2 + 1);
> -             if (ssid == NULL)
> -                     break;
> +                     ssid = g_try_malloc0(hex_ssid_len / 2 + 1);
> +                     if (ssid == NULL)
> +                             break;
>  
> -             for (j = 0, k = 0; j < hex_ssid_len; j += 2) {
> -                     sscanf(hex_ssid + j, "%02x", &hex);
> -                     ssid[k++] = hex;
> -             }
> +                     for (j = 0, k = 0; j < hex_ssid_len; j += 2) {
> +                             sscanf(hex_ssid + j, "%02x", &hex);
> +                             ssid[k++] = hex;
> +                     }
>  
> -             if (add_hidden_network(task, ssid, hex_ssid_len / 2) < 0)
> -                     break;
> +                     if (add_hidden_network(task, ssid, hex_ssid_len / 2) < 
> 0)
> +                             break;
> +             }
> +             g_strfreev(hex_ssids);
>       }
>  
> -     g_strfreev(hex_ssids);
> -
>       dbus_message_unref(reply);
>  
>       dbus_pending_call_unref(call);
> 
> -- 
> David Woodhouse                            Open Source Technology Centre
> [email protected]                              Intel Corporation
> 
> 
> _______________________________________________
> connman mailing list
> [email protected]
> http://lists.connman.net/listinfo/connman

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to