rc-selinux.c: remove references to path_max

This commit is contained in:
William Hubbs 2018-02-20 16:35:50 -06:00
parent 3c031ca978
commit c1178c8eeb

View File

@ -256,19 +256,19 @@ static int read_context_file(const char *filename, char **context)
{ {
int ret = -1; int ret = -1;
FILE *fp; FILE *fp;
char filepath[PATH_MAX]; char *filepath = NULL;
char *line = NULL; char *line = NULL;
char *p; char *p;
char *p2; char *p2;
size_t len = 0; size_t len = 0;
ssize_t read; ssize_t read;
memset(filepath, '\0', PATH_MAX); xasprintf(&filepath, "%s/%s", selinux_contexts_path(), filename);
snprintf(filepath, PATH_MAX - 1, "%s/%s", selinux_contexts_path(), filename);
fp = fopen(filepath, "r"); fp = fopen(filepath, "r");
if (fp == NULL) { if (fp == NULL) {
eerror("Failed to open context file: %s", filename); eerror("Failed to open context file: %s", filename);
free(filepath);
return -1; return -1;
} }
@ -294,6 +294,7 @@ static int read_context_file(const char *filename, char **context)
} }
free(line); free(line);
free(filepath);
fclose(fp); fclose(fp);
return ret; return ret;
} }