libselinux: audit2why: make sure path is nul terminated

We use strncpy which could leave a non-nul terminated string if the
source is longer than PATH_MAX.  Add that nul.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
Eric Paris 2012-12-04 15:23:57 -05:00
parent 960d6ee879
commit 933840af6c

View File

@ -195,8 +195,9 @@ static int __policy_init(const char *init_path)
int rc;
unsigned int cnt;
path[PATH_MAX-1] = '\0';
if (init_path) {
strncpy(path, init_path, PATH_MAX);
strncpy(path, init_path, PATH_MAX-1);
fp = fopen(path, "r");
if (!fp) {
snprintf(errormsg, sizeof(errormsg),