Skip to content

Commit 20a8d62

Browse files
stephensmalleypcmoore
authored andcommitted
selinux: genheaders should fail if too many permissions are defined
Ensure that genheaders fails with an error if too many permissions are defined in a class to fit within an access vector. This is similar to a check performed by checkpolicy when compiling the policy. Also, fix the suffix on the permission constants generated by this program. Signed-off-by: Stephen Smalley <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent cd0d877 commit 20a8d62

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/selinux/genheaders/genheaders.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,16 @@ int main(int argc, char *argv[])
129129
for (i = 0; secclass_map[i].name; i++) {
130130
struct security_class_mapping *map = &secclass_map[i];
131131
for (j = 0; map->perms[j]; j++) {
132+
if (j >= 32) {
133+
fprintf(stderr, "Too many permissions to fit into an access vector at (%s, %s).\n",
134+
map->name, map->perms[j]);
135+
exit(5);
136+
}
132137
fprintf(fout, "#define %s__%s", map->name,
133138
map->perms[j]);
134139
for (k = 0; k < max(1, 40 - strlen(map->name) - strlen(map->perms[j])); k++)
135140
fprintf(fout, " ");
136-
fprintf(fout, "0x%08xUL\n", (1<<j));
141+
fprintf(fout, "0x%08xU\n", (1<<j));
137142
}
138143
}
139144

0 commit comments

Comments
 (0)