Skip to content

Commit 7178784

Browse files
Dmitry KasatkinMimi Zohar
authored andcommitted
ima: ignore empty and with whitespaces policy lines
Empty policy lines cause parsing failures which is, especially for new users, hard to spot. This patch prevents it. Changes in v2: * strip leading blanks and tabs in rules to prevent parsing failures Signed-off-by: Dmitry Kasatkin <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 272a6e9 commit 7178784

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

security/integrity/ima/ima_policy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,9 @@ ssize_t ima_parse_add_rule(char *rule)
696696

697697
p = strsep(&rule, "\n");
698698
len = strlen(p) + 1;
699+
p += strspn(p, " \t");
699700

700-
if (*p == '#')
701+
if (*p == '#' || *p == '\0')
701702
return len;
702703

703704
entry = kzalloc(sizeof(*entry), GFP_KERNEL);

0 commit comments

Comments
 (0)