[PATCHv2 1/2] hostapd: make it possible to remove addresses from maclists

Jouni Malinen j at w1.fi
Mon Feb 24 16:12:54 EST 2014


On Wed, Feb 19, 2014 at 03:53:15PM +0100, Emanuel Taube wrote:
> It is already possible to add mac addresses at runtime.
> This patch allows also to remove some of them by the prefix "-"
> in the address file.

> diff --git a/hostapd/config_file.c b/hostapd/config_file.c
> @@ -116,6 +116,8 @@ static int hostapd_config_read_maclist(const char *fname,
> +	Boolean remove;
> +	int i;

> +		if (remove) {
> +			for (i = 0; i < *num; i++)
> +				if (os_memcmp((*acl)[i].addr, addr, ETH_ALEN) ==
> +				    0) {
> +					os_remove_in_array(
> +						*acl, *num,
> +						sizeof(**acl), i--);
> +					(*num)--;

While this may be correct, that i-- hidden in the os_remove_in_array()
call is a bit dubious.. How about using a while loop with that branch
not incrementing i? I would also like to see braces around the for loop
body since it has that many lines.

-- 
Jouni Malinen                                            PGP id EFC895FA


More information about the HostAP mailing list