From c1178c8eebb92c9f3702e981cd4af9ef41f51884 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Tue, 20 Feb 2018 16:35:50 -0600 Subject: rc-selinux.c: remove references to path_max --- src/rc/rc-selinux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3