1 |
commit: c1178c8eebb92c9f3702e981cd4af9ef41f51884 |
2 |
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue Feb 20 22:35:50 2018 +0000 |
4 |
Commit: William Hubbs <williamh <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Feb 20 22:35:50 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c1178c8e |
7 |
|
8 |
rc-selinux.c: remove references to path_max |
9 |
|
10 |
src/rc/rc-selinux.c | 7 ++++--- |
11 |
1 file changed, 4 insertions(+), 3 deletions(-) |
12 |
|
13 |
diff --git a/src/rc/rc-selinux.c b/src/rc/rc-selinux.c |
14 |
index bfaf1556..2c9673cc 100644 |
15 |
--- a/src/rc/rc-selinux.c |
16 |
+++ b/src/rc/rc-selinux.c |
17 |
@@ -256,19 +256,19 @@ static int read_context_file(const char *filename, char **context) |
18 |
{ |
19 |
int ret = -1; |
20 |
FILE *fp; |
21 |
- char filepath[PATH_MAX]; |
22 |
+ char *filepath = NULL; |
23 |
char *line = NULL; |
24 |
char *p; |
25 |
char *p2; |
26 |
size_t len = 0; |
27 |
ssize_t read; |
28 |
|
29 |
- memset(filepath, '\0', PATH_MAX); |
30 |
- snprintf(filepath, PATH_MAX - 1, "%s/%s", selinux_contexts_path(), filename); |
31 |
+ xasprintf(&filepath, "%s/%s", selinux_contexts_path(), filename); |
32 |
|
33 |
fp = fopen(filepath, "r"); |
34 |
if (fp == NULL) { |
35 |
eerror("Failed to open context file: %s", filename); |
36 |
+ free(filepath); |
37 |
return -1; |
38 |
} |
39 |
|
40 |
@@ -294,6 +294,7 @@ static int read_context_file(const char *filename, char **context) |
41 |
} |
42 |
|
43 |
free(line); |
44 |
+ free(filepath); |
45 |
fclose(fp); |
46 |
return ret; |
47 |
} |