Skip to content

Commit

Permalink
ima: ignore empty and with whitespaces policy lines
Browse files Browse the repository at this point in the history
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 <d.kasatkin@samsung.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
  • Loading branch information
Dmitry Kasatkin authored and Mimi Zohar committed Oct 12, 2014
1 parent 272a6e9 commit 7178784
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion security/integrity/ima/ima_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,9 @@ ssize_t ima_parse_add_rule(char *rule)

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

if (*p == '#')
if (*p == '#' || *p == '\0')
return len;

entry = kzalloc(sizeof(*entry), GFP_KERNEL);
Expand Down

0 comments on commit 7178784

Please sign in to comment.