From: Etienne CHAMPETIER Date: Fri, 27 Nov 2015 16:27:09 +0000 (+0000) Subject: ujail: use PATH_MAX for path related buffers X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fprocd.git;a=commitdiff_plain;h=7e5751fd776bb53884ecc211a7f5026de7db94d4 ujail: use PATH_MAX for path related buffers Signed-off-by: Etienne CHAMPETIER --- diff --git a/jail/elf.c b/jail/elf.c index 5e22606..2acac71 100644 --- a/jail/elf.c +++ b/jail/elf.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -72,7 +73,7 @@ static void alloc_library(const char *path, const char *name) static int elf_open(char **dir, const char *file) { struct library_path *p; - char path[256]; + char path[PATH_MAX]; int fd = -1; *dir = NULL; @@ -98,7 +99,7 @@ static int elf_open(char **dir, const char *file) const char* find_lib(const char *file) { struct library *l; - static char path[256]; + static char path[PATH_MAX]; const char *p; l = avl_find_element(&libraries, file, l, avl); @@ -313,7 +314,7 @@ err_out: void load_ldso_conf(const char *conf) { FILE* fp = fopen(conf, "r"); - char line[256]; + char line[PATH_MAX]; if (!fp) { DEBUG("failed to open %s\n", conf); @@ -323,7 +324,7 @@ void load_ldso_conf(const char *conf) while (!feof(fp)) { int len; - if (!fgets(line, 256, fp)) + if (!fgets(line, sizeof(line), fp)) break; len = strlen(line); if (len < 2) diff --git a/jail/jail.c b/jail/jail.c index e8c8f08..90aa482 100644 --- a/jail/jail.c +++ b/jail/jail.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "elf.h" #include "capabilities.h" @@ -93,8 +94,8 @@ static int mount_bind(const char *root, const char *path, const char *name, int { const char *p = path; struct stat s; - char old[256]; - char new[256]; + char old[PATH_MAX]; + char new[PATH_MAX]; int fd; if (strstr(p, "local")) @@ -209,8 +210,8 @@ static int build_jail_fs() static char** build_envp(const char *seccomp) { static char *envp[MAX_ENVP]; - static char preload_var[64]; - static char seccomp_var[64]; + static char preload_var[PATH_MAX]; + static char seccomp_var[PATH_MAX]; static char debug_var[] = "LD_DEBUG=all"; const char *preload_lib = find_lib("libpreload-seccomp.so"); int count = 0;