5f9af7f
From a089634c855312a28f2ff3c2e7c08df5d030e2f5 Mon Sep 17 00:00:00 2001
5f9af7f
From: Jim Meyering <meyering <at> redhat.com>
5f9af7f
Date: Tue, 20 May 2008 17:58:42 +0200
5f9af7f
Subject: [PATCH] install: avoid a leak in currently-ifdef'd-out code
5f9af7f
5f9af7f
* src/install.c (setdefaultfilecon)
5f9af7f
[ENABLE_WHEN_MATCHPATHCON_IS_MORE_EFFICIENT]:
5f9af7f
Call matchpathcon_init_prefix only once.
5f9af7f
Suggestion from Stephen Smalley.  Reported by Ben Webb in
5f9af7f
<http://bugzilla.redhat.com/447410>.
5f9af7f
---
5f9af7f
 src/install.c |    5 ++++-
5f9af7f
 1 files changed, 4 insertions(+), 1 deletions(-)
5f9af7f
5f9af7f
diff --git a/src/install.c b/src/install.c
5f9af7f
index 964ab36..b531f45 100644
5f9af7f
--- a/src/install.c
5f9af7f
+++ b/src/install.c
5f9af7f
@@ -208,6 +208,8 @@ setdefaultfilecon (char const *file)
26314cd
 {
26314cd
   struct stat st;
5f9af7f
   security_context_t scontext = NULL;
5f9af7f
+  static bool first_call = true;
5f9af7f
+
26314cd
   if (selinux_enabled != 1)
26314cd
     {
26314cd
       /* Indicate no context found. */
5f9af7f
@@ -216,7 +218,7 @@ setdefaultfilecon (char const *file)
26314cd
   if (lstat (file, &st) != 0)
26314cd
     return;
5f9af7f
5f9af7f
-  if (IS_ABSOLUTE_FILE_NAME (file))
5f9af7f
+  if (first_call && IS_ABSOLUTE_FILE_NAME (file))
26314cd
     {
5f9af7f
       /* Calling matchpathcon_init_prefix (NULL, "/first_component/")
26314cd
 	 is an optimization to minimize the expense of the following
5f9af7f
@@ -247,6 +249,7 @@ setdefaultfilecon (char const *file)
5f9af7f
 	    }
26314cd
 	}
26314cd
     }
5f9af7f
+  first_call = false;
5f9af7f
26314cd
   /* If there's an error determining the context, or it has none,
26314cd
      return to allow default context */
5f9af7f
--
5f9af7f
1.5.5.1.249.g68ef3