Skip to content

Commit

Permalink
ima: store address of template_fmt_copy in a pointer before calling s…
Browse files Browse the repository at this point in the history
…trsep

This patch stores the address of the 'template_fmt_copy' variable in a new
variable, called 'template_fmt_ptr', so that the latter is passed as an
argument of strsep() instead of the former. This modification is needed
in order to correctly free the memory area referenced by
'template_fmt_copy' (strsep() modifies the pointer of the passed string).

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Reported-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
  • Loading branch information
Roberto Sassu authored and James Morris committed Nov 30, 2013
1 parent dc1ccc4 commit af91706
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions security/integrity/ima/ima_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static int template_desc_init_fields(const char *template_fmt,
struct ima_template_field ***fields,
int *num_fields)
{
char *c, *template_fmt_copy;
char *c, *template_fmt_copy, *template_fmt_ptr;
int template_num_fields = template_fmt_size(template_fmt);
int i, result = 0;

Expand All @@ -127,7 +127,9 @@ static int template_desc_init_fields(const char *template_fmt,
result = -ENOMEM;
goto out;
}
for (i = 0; (c = strsep(&template_fmt_copy, "|")) != NULL &&

template_fmt_ptr = template_fmt_copy;
for (i = 0; (c = strsep(&template_fmt_ptr, "|")) != NULL &&
i < template_num_fields; i++) {
struct ima_template_field *f = lookup_template_field(c);

Expand Down

0 comments on commit af91706

Please sign in to comment.