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:
parent
7a86fe1a3d
commit
8720c8e576
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue