Fix handling of subset labeling that is causing segfault in restorecon

This commit is contained in:
Dan Walsh 2011-09-06 09:46:57 -04:00
parent 10e77a8370
commit c03bd38197
2 changed files with 15 additions and 10 deletions

View File

@ -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

View File

@ -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@redhat.com> - 2.1.5-3
- Fix handling of subset labeling that is causing segfault in restorecon
* Fri Sep 2 2011 Dan Walsh <dwalsh@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