Re: [PATCH] hostapd_acl_recv_radius: tagged is a pointer, not an int

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

vlan_id.tagged is int[MAX_NUM_TAGGED_VLAN].

I tested the assignments with a minimal test case (attached) using
struct vlan_description with gcc 4.9.2.

1. int * tagged = vlan_id.tagged
  -> accepted without warning

2. int * tagged = &vlan_id.tagged
  -> warning: initialization from incompatible pointer type

So I think the patch not correct.

But interestingly, both vlan_id.tagged and &vlan_id.taged resolve to the
same pointer value for me.

Regards,
M. Braun

Am 05.11.2016 um 01:06 schrieb Derrick Pallas:
> Discovered & fixed by Louisa Chong, `tagged` is an `int*`, not an `int`, so
> we actually want to take the address of `cache->vlan_id.tagged` here.
> 
> Signed-off-by: Louisa Chong <clouisa@xxxxxxxxxx>
> Signed-off-by: Derrick Pallas <pallas@xxxxxxxxxx>
> ---
>  src/ap/ieee802_11_auth.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/ap/ieee802_11_auth.c b/src/ap/ieee802_11_auth.c
> index b890537..86230c9 100644
> --- a/src/ap/ieee802_11_auth.c
> +++ b/src/ap/ieee802_11_auth.c
> @@ -569,7 +569,7 @@ hostapd_acl_recv_radius(struct radius_msg *msg, struct radius_msg *req,
>  
>  		notempty = &cache->vlan_id.notempty;
>  		untagged = &cache->vlan_id.untagged;
> -		tagged = cache->vlan_id.tagged;
> +		tagged = &cache->vlan_id.tagged;
>  		*notempty = !!radius_msg_get_vlanid(msg, untagged,
>  						    MAX_NUM_TAGGED_VLAN,
>  						    tagged);
> 

#include <stdio.h>

#define MAX_NUM_TAGGED_VLAN 10

struct vlan_description {
        int notempty; /* 0 : no vlan information present, 1: else */
        int untagged; /* >0 802.1q vid */
        int tagged[MAX_NUM_TAGGED_VLAN]; /* first k items, ascending order */
};


int main() {
        struct vlan_description v;
        void * vp = &v;
        int * vt = v.tagged;
        int * vtt = &v.tagged;

        int x = (long long) vt - (long long) vp;
        printf("%p %p %p\n",vp, vt, vtt);

        return 0;
}
_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap

[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux