commit: c1178c8eebb92c9f3702e981cd4af9ef41f51884
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Feb 20 22:35:50 2018 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Feb 20 22:35:50 2018 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c1178c8e
rc-selinux.c: remove references to path_max
src/rc/rc-selinux.c | 7 ++++---
1 file 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;
}