[BZ,#16877] Fix typo in nscd/selinux.c
diff mbox

Message ID 20140427181904.GA31159@domone.podge
State New
Headers show

Commit Message

Ondřej Bílka April 27, 2014, 6:19 p.m. UTC
This bug is another report of typo in code. A perm variable 
is unitialized so there could be spurious error message 
depending how gcc optimizes this. This could be changed into
intended check as below.

OK to commit this?

	[BZ #16877]
	* nscd/selinux.c (nscd_request_avc_has_perm): Check if there is
	nscd security class.

Comments

Ondřej Bílka May 3, 2014, 9:18 a.m. UTC | #1
On Sun, Apr 27, 2014 at 08:19:04PM +0200, Ondřej Bílka wrote:
> 
> This bug is another report of typo in code. A perm variable 
> is unitialized so there could be spurious error message 
> depending how gcc optimizes this. This could be changed into
> intended check as below.
> 
> OK to commit this?
> 
> 	[BZ #16877]
> 	* nscd/selinux.c (nscd_request_avc_has_perm): Check if there is
> 	nscd security class.
> 
> diff --git a/nscd/selinux.c b/nscd/selinux.c
> index 9a8a5a8..eaed6dd 100644
> --- a/nscd/selinux.c
> +++ b/nscd/selinux.c
> @@ -372,7 +372,7 @@ nscd_request_avc_has_perm (int fd, request_type req)
>    /* Get the security class for nscd.  If this fails we will likely be
>       unable to do anything unless avc_deny_unknown is 0.  */
>    sc_nscd = string_to_security_class ("nscd");
> -  if (perm == 0 && avc_deny_unknown == 1)
> +  if (sc_nscd == 0 && avc_deny_unknown == 1)
>      dbg_log (_("Error getting security class for nscd."));
>  
>    /* Convert permission to AVC bits.  */
Will Newton May 6, 2014, 8:26 a.m. UTC | #2
On 27 April 2014 19:19, Ondřej Bílka <neleai@seznam.cz> wrote:
>
> This bug is another report of typo in code. A perm variable
> is unitialized so there could be spurious error message
> depending how gcc optimizes this. This could be changed into
> intended check as below.
>
> OK to commit this?
>
>         [BZ #16877]
>         * nscd/selinux.c (nscd_request_avc_has_perm): Check if there is
>         nscd security class.

This looks ok to me and fixes the build warning.

> diff --git a/nscd/selinux.c b/nscd/selinux.c
> index 9a8a5a8..eaed6dd 100644
> --- a/nscd/selinux.c
> +++ b/nscd/selinux.c
> @@ -372,7 +372,7 @@ nscd_request_avc_has_perm (int fd, request_type req)
>    /* Get the security class for nscd.  If this fails we will likely be
>       unable to do anything unless avc_deny_unknown is 0.  */
>    sc_nscd = string_to_security_class ("nscd");
> -  if (perm == 0 && avc_deny_unknown == 1)
> +  if (sc_nscd == 0 && avc_deny_unknown == 1)
>      dbg_log (_("Error getting security class for nscd."));
>
>    /* Convert permission to AVC bits.  */

Patch
diff mbox

diff --git a/nscd/selinux.c b/nscd/selinux.c
index 9a8a5a8..eaed6dd 100644
--- a/nscd/selinux.c
+++ b/nscd/selinux.c
@@ -372,7 +372,7 @@  nscd_request_avc_has_perm (int fd, request_type req)
   /* Get the security class for nscd.  If this fails we will likely be
      unable to do anything unless avc_deny_unknown is 0.  */
   sc_nscd = string_to_security_class ("nscd");
-  if (perm == 0 && avc_deny_unknown == 1)
+  if (sc_nscd == 0 && avc_deny_unknown == 1)
     dbg_log (_("Error getting security class for nscd."));
 
   /* Convert permission to AVC bits.  */