Re: [PATCH 3/3] libsepol: fix unitialized variable 'nread' on mac build

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

 



On 09/23/2016 04:55 PM, william.c.roberts@xxxxxxxxx wrote:
> From: William Roberts <william.c.roberts@xxxxxxxxx>
> 
> Fix this:
> genusers.c:63:14: warning: variable 'nread' is uninitialized when used here [-Wuninitialized]
>                 if (buffer[nread - 1] == '\n')
>                            ^~~~~
> genusers.c:40:15: note: initialize the variable 'nread' to silence this warning
>         ssize_t nread;
>                      ^
>                       = 0
> 
> Signed-off-by: William Roberts <william.c.roberts@xxxxxxxxx>

Thanks, applied all 3 patches.
NB none of this code is actually used on the Mac or elsewhere in Android
for that matter, and even on Linux, it is just legacy code (not used in
modern distributions).

> ---
>  libsepol/src/genusers.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libsepol/src/genusers.c b/libsepol/src/genusers.c
> index 57a9a2e..5568210 100644
> --- a/libsepol/src/genusers.c
> +++ b/libsepol/src/genusers.c
> @@ -53,6 +53,7 @@ static int load_users(struct policydb *policydb, const char *path)
>  	}
>  
>  	while(fgets(buffer, 255, fp) != NULL) {
> +		nread = strlen(buffer);
>  #else
>  	size_t len = 0;
>  	__fsetlocking(fp, FSETLOCKING_BYCALLER);
> 

_______________________________________________
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