aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rc/rc-selinux.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c
index bfaf1556..2c9673cc 100644
--- a/src/rc/rc-selinux.c
+++ b/src/rc/rc-selinux.c
@@ -256,19 +256,19 @@ static int read_context_file(const char *filename, char **context)
{
int ret = -1;
FILE *fp;
- char filepath[PATH_MAX];
+ char *filepath = NULL;
char *line = NULL;
char *p;
char *p2;
size_t len = 0;
ssize_t read;
- memset(filepath, '\0', PATH_MAX);
- snprintf(filepath, PATH_MAX - 1, "%s/%s", selinux_contexts_path(), filename);
+ xasprintf(&filepath, "%s/%s", selinux_contexts_path(), filename);
fp = fopen(filepath, "r");
if (fp == NULL) {
eerror("Failed to open context file: %s", filename);
+ free(filepath);
return -1;
}
@@ -294,6 +294,7 @@ static int read_context_file(const char *filename, char **context)
}
free(line);
+ free(filepath);
fclose(fp);
return ret;
}