libsepol: allocate enough space to hold filename in trans rules

There is an off by one bug in which the filename length stored with
filename_trans_rules is stored as strlen (aka, no nul) however the
code to allocate space and read the name back in from policy only
allocates len, and not the len + 1 needed to hold the nul.  Allocate
enough space for the nul.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
Eric Paris 2012-04-23 16:13:46 -04:00
parent 7a86fe1a3d
commit 8720c8e576
1 changed files with 1 additions and 1 deletions

View File

@ -2380,7 +2380,7 @@ int filename_trans_read(filename_trans_t **t, struct policy_file *fp)
return -1;
len = le32_to_cpu(buf[0]);
name = calloc(len, sizeof(*name));
name = calloc(len + 1, sizeof(*name));
if (!name)
return -1;