[libselinux] Fix handling of subset labeling that is causing segfault in restorecon
Daniel J Walsh
dwalsh at fedoraproject.org
Tue Sep 6 14:03:32 UTC 2011
commit c03bd3819704ad66bb0d90a234228dec16652cdb
Author: Dan Walsh <dwalsh at redhat.com>
Date: Tue Sep 6 09:46:57 2011 -0400
Fix handling of subset labeling that is causing segfault in restorecon
libselinux-rhat.patch | 20 +++++++++++---------
libselinux.spec | 5 ++++-
2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/libselinux-rhat.patch b/libselinux-rhat.patch
index 6e76064..60675f0 100644
--- a/libselinux-rhat.patch
+++ b/libselinux-rhat.patch
@@ -56,7 +56,7 @@ index b245364..7c47222 100644
rc = vfprintf(stderr, fmt, ap);
va_end(ap);
diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
-index 3b8346d..0d89dcb 100644
+index 3b8346d..ead3b0b 100644
--- a/libselinux/src/label_file.c
+++ b/libselinux/src/label_file.c
@@ -27,6 +27,7 @@
@@ -116,7 +116,7 @@ index 3b8346d..0d89dcb 100644
FILE *fp;
FILE *localfp = NULL;
FILE *homedirfp = NULL;
-@@ -421,8 +434,17 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
+@@ -421,8 +434,19 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
path = opts[n].value;
break;
case SELABEL_OPT_SUBSET:
@@ -124,10 +124,12 @@ index 3b8346d..0d89dcb 100644
+ {
+ char *ptr;
+ i = 0;
-+ prefix_array[i] = strtok_r((char *)opts[n].value, ";", &ptr);
-+ while ((prefix_array[i] != NULL) && i < MAX_PREFIX - 1) {
-+ i++;
-+ prefix_array[i] = strtok_r(NULL, ";", &ptr);
++ if (opts[n].value) {
++ prefix_array[i] = strtok_r((char *)opts[n].value, ";", &ptr);
++ while ((prefix_array[i] != NULL) && i < MAX_PREFIX - 1) {
++ i++;
++ prefix_array[i] = strtok_r(NULL, ";", &ptr);
++ }
+ }
+
break;
@@ -135,7 +137,7 @@ index 3b8346d..0d89dcb 100644
case SELABEL_OPT_BASEONLY:
baseonly = !!opts[n].value;
break;
-@@ -481,7 +503,7 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
+@@ -481,7 +505,7 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
data->ncomp = 0;
while (getline(&line_buf, &line_len, fp) > 0
&& data->nspec < maxnspec) {
@@ -144,7 +146,7 @@ index 3b8346d..0d89dcb 100644
pass, ++lineno) != 0)
goto finish;
}
-@@ -495,7 +517,7 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
+@@ -495,7 +519,7 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
while (getline(&line_buf, &line_len, homedirfp) > 0
&& data->nspec < maxnspec) {
if (process_line
@@ -153,7 +155,7 @@ index 3b8346d..0d89dcb 100644
line_buf, pass, ++lineno) != 0)
goto finish;
}
-@@ -505,7 +527,7 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
+@@ -505,7 +529,7 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts,
while (getline(&line_buf, &line_len, localfp) > 0
&& data->nspec < maxnspec) {
if (process_line
diff --git a/libselinux.spec b/libselinux.spec
index 0aadae5..b6982af 100644
--- a/libselinux.spec
+++ b/libselinux.spec
@@ -7,7 +7,7 @@
Summary: SELinux library and simple utilities
Name: libselinux
Version: 2.1.5
-Release: 2%{?dist}
+Release: 3%{?dist}
License: Public Domain
Group: System Environment/Libraries
Source: %{name}-%{version}.tgz
@@ -233,6 +233,9 @@ exit 0
%{ruby_sitearch}/selinux.so
%changelog
+* Tue Sep 6 2011 Dan Walsh <dwalsh at redhat.com> - 2.1.5-3
+- Fix handling of subset labeling that is causing segfault in restorecon
+
* Fri Sep 2 2011 Dan Walsh <dwalsh at redhat.com> - 2.1.5-2
- Change matchpathcon_init_prefix and selabel_open to allow multiple initial
prefixes. Now you can specify a ";" separated list of prefixes and the
More information about the scm-commits
mailing list