Fix handling of libselinux getconlist with only one entry

This commit is contained in:
Dan Walsh 2013-09-16 17:29:19 -04:00
parent a21a1b7e23
commit 2bfbe603e1
2 changed files with 11 additions and 5 deletions

View File

@ -706,7 +706,7 @@ index 802a07f..6ff83a7 100644
} }
diff --git a/libselinux/src/get_context_list.c b/libselinux/src/get_context_list.c diff --git a/libselinux/src/get_context_list.c b/libselinux/src/get_context_list.c
index b9e8002..355730a 100644 index b9e8002..1d91123 100644
--- a/libselinux/src/get_context_list.c --- a/libselinux/src/get_context_list.c
+++ b/libselinux/src/get_context_list.c +++ b/libselinux/src/get_context_list.c
@@ -426,7 +426,7 @@ int get_ordered_context_list(const char *user, @@ -426,7 +426,7 @@ int get_ordered_context_list(const char *user,
@ -727,8 +727,11 @@ index b9e8002..355730a 100644
snprintf(fname, fname_len, "%s%s", user_contexts_path, user); snprintf(fname, fname_len, "%s%s", user_contexts_path, user);
fp = fopen(fname, "r"); fp = fopen(fname, "r");
if (fp) { if (fp) {
@@ -465,31 +465,28 @@ int get_ordered_context_list(const char *user, @@ -463,33 +463,31 @@ int get_ordered_context_list(const char *user,
__FUNCTION__, selinux_default_context_path());
/* Fall through */
} }
+ rc = 0;
} }
+ if (!nordered) + if (!nordered)
@ -764,7 +767,7 @@ index b9e8002..355730a 100644
- to the caller. Otherwise, fall back to the entire reachable list. */ - to the caller. Otherwise, fall back to the entire reachable list. */
- if (nordered && nordered < nreach) { - if (nordered && nordered < nreach) {
+ /* Only report the ordered entries to the caller. */ + /* Only report the ordered entries to the caller. */
+ if (nordered < nreach) { + if (nordered <= nreach) {
for (i = nordered; i < nreach; i++) for (i = nordered; i < nreach; i++)
free(reachable[i]); free(reachable[i]);
reachable[nordered] = NULL; reachable[nordered] = NULL;
@ -774,7 +777,7 @@ index b9e8002..355730a 100644
} }
out: out:
@@ -523,14 +520,6 @@ int get_ordered_context_list(const char *user, @@ -523,14 +521,6 @@ int get_ordered_context_list(const char *user,
} }
rc = 1; /* one context in the list */ rc = 1; /* one context in the list */
goto out; goto out;

View File

@ -10,7 +10,7 @@
Summary: SELinux library and simple utilities Summary: SELinux library and simple utilities
Name: libselinux Name: libselinux
Version: 2.1.13 Version: 2.1.13
Release: 18%{?dist} Release: 19%{?dist}
License: Public Domain License: Public Domain
Group: System Environment/Libraries Group: System Environment/Libraries
Source: %{name}-%{version}.tgz Source: %{name}-%{version}.tgz
@ -240,6 +240,9 @@ rm -rf %{buildroot}
%{ruby_sitearch}/selinux.so %{ruby_sitearch}/selinux.so
%changelog %changelog
* Mon Sep 16 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.13-19
- Fix handling of libselinux getconlist with only one entry
* Tue Sep 3 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.13-17 * Tue Sep 3 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.13-17
- Add Python constants for SELinux enforcing modes - Add Python constants for SELinux enforcing modes