[PATCH 4/7] Adding ctrl iface command for autoscan

Jouni Malinen j at w1.fi
Sun Jun 24 05:59:18 EDT 2012


On Thu, May 03, 2012 at 04:16:53PM +0300, Tomasz Bursztyka wrote:
> diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
> +#ifdef CONFIG_AUTOSCAN
> +
> +static int wpa_supplicant_ctrl_iface_autoscan(struct wpa_supplicant *wpa_s,
> +					      char *cmd)
> +{
> +	enum wpa_states state = wpa_s->wpa_state;
> +
> +	if (wpa_s->conf->autoscan != NULL) {
> +		os_free(wpa_s->conf->autoscan);
> +		wpa_s->conf->autoscan = NULL;
> +	}

The previously used parameter should not be cleared before this command
execution has been completed successfully.

> +	if (cmd != NULL && os_strlen(cmd) > 0) {

cmd cannot be NULL here, so that "cmd != NULL && " part is unnecessary.

> +		wpa_s->conf->autoscan = os_strdup(cmd);
> +		if (wpa_s->conf->autoscan == NULL)
> +			return -1;
> +
> +		if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
> +			autoscan_init(wpa_s);
> +	} else if (os_strlen(cmd) == 0)

And if cmd could have been NULL, this would segfault on NULL pointer
dereference..

-- 
Jouni Malinen                                            PGP id EFC895FA


More information about the HostAP mailing list