[PATCH 2/3] policycoreutils/hll/pp: fix '\n' parsing in filecon statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some module fc files do not contain a trailing new line. This
caused contexts to have their last character to be deleted. When
parsing each line from a fc file, we only strip off the last character
if it is a new line.

Signed-off-by: Yuli Khodorkovskiy <ykhodorkovskiy@xxxxxxxxxx>
---
 policycoreutils/hll/pp/pp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/policycoreutils/hll/pp/pp.c b/policycoreutils/hll/pp/pp.c
index d424f80..55cf819 100644
--- a/policycoreutils/hll/pp/pp.c
+++ b/policycoreutils/hll/pp/pp.c
@@ -2753,7 +2753,9 @@ static int file_contexts_to_cil(struct sepol_module_package *mod_pkg)
 	fp = fmemopen(fc, fc_len, "r");
 	while ((line_len = getline(&line, &len, fp)) != -1) {
 		buf = line;
-		buf[line_len - 1] = '\0';
+		if (buf[line_len - 1] == '\n') {
+			buf[line_len - 1] = '\0';
+		}
 		while (*buf && isspace(buf[0])) {
 			buf++;
 		}
-- 
1.9.3

_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux