policycoreutils/hll/pp: fix '\n' parsing in filecon statements

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@tresys.com>
Acked-by: Steve Lawrence <slawrence@tresys.com>
This commit is contained in:
Yuli Khodorkovskiy 2014-10-01 15:28:29 -04:00 committed by Steve Lawrence
parent f42d013eec
commit 836ffd988e

View file

@ -2756,7 +2756,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++;
}