Re: [PATCH] libselinux: drop usage of _D_ALLOC_NAMLEN

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

 



On 09/23/2016 02:02 PM, william.c.roberts@xxxxxxxxx wrote:
> From: William Roberts <william.c.roberts@xxxxxxxxx>
> 
> _D_ALLOC_NAMLEN is not very portable. Currently, the code
> mallocs based on _D_ALLOC_NAMLEN() and then strcpy's dirent
> d_name into the buffer. Instead, just use strdup.
> 
> Change-Id: I5c8ca47da2c593ea2726caba5781f5e9d9d910ae
> Signed-off-by: William Roberts <william.c.roberts@xxxxxxxxx>

Thanks, applied.

> ---
>  libselinux/src/booleans.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libselinux/src/booleans.c b/libselinux/src/booleans.c
> index 4b39a28..c438af1 100644
> --- a/libselinux/src/booleans.c
> +++ b/libselinux/src/booleans.c
> @@ -63,12 +63,11 @@ int security_get_boolean_names(char ***names, int *len)
>  	}
>  
>  	for (i = 0; i < *len; i++) {
> -		n[i] = (char *)malloc(_D_ALLOC_NAMLEN(namelist[i]));
> +		n[i] = strdup(namelist[i]->d_name);
>  		if (!n[i]) {
>  			rc = -1;
>  			goto bad_freen;
>  		}
> -		strcpy(n[i], namelist[i]->d_name);
>  	}
>  	rc = 0;
>  	*names = n;
> 

_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux