Skip to contentSkip to conversation

policycoreutils/hll/pp: Fix pp crash when processing base module

PATCH Applied Vit Mojzis 2 participants 2 messages Jan 19, 2017 SELinux security module

lore
Share & tools
lore

Vit Mojzis

author
#0 lore raw

PATCH 1/1 policycoreutils/hll/pp: Fix pp crash when processing base module

Policy module structure created by libsepol out of base module contains NULL in module name, which results in segfault in "pp" compiler. Add NULL check.

---
 policycoreutils/hll/pp/pp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
policycoreutils/hll/pp/pp.c +1 -1
index 2c9f53f..7f9afb0 100644
@@ -141,7 +141,7 @@ int main(int argc, char **argv)
 		if (separator) {
 			*separator = '\0';
 		}
-		if (strcmp(mod_name, cil_name) != 0) {
+		if (mod_name && strcmp(mod_name, cil_name) != 0) {
 			fprintf(stderr,	"Warning: SELinux userspace will refer to the module from %s as %s rather than %s\n", ifile, mod_name, cil_name);
 		}
 		free(cil_path);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 5 lines · Vit Mojzis

Policy module structure created by libsepol out of base module contains NULL in module name, which results in segfault in "pp" compiler. Add NULL check.

Thanks, applied.

Quoted 22 lines

---
 policycoreutils/hll/pp/pp.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
policycoreutils/hll/pp/pp.c +1 -1
index 2c9f53f..7f9afb0 100644
@@ -141,7 +141,7 @@ int main(int argc, char **argv)
  		if (separator) {
  			*separator = '\0';
  		}
-		if (strcmp(mod_name, cil_name) != 0) {
+		if (mod_name && strcmp(mod_name, cil_name) != 0) {

  fprintf(stderr, "Warning: SELinux
userspace will refer to the module from %s as %s rather than %s\n", ifile, mod_name, cil_name);
  }
  free(cil_path);