[OpenWrt-Devel] [PATCH procd v2 10/17] ujail: use PATH_MAX for path related buffers
Etienne CHAMPETIER
champetier.etienne at gmail.com
Wed Nov 25 12:54:43 EST 2015
Signed-off-by: Etienne CHAMPETIER <champetier.etienne at gmail.com>
---
jail/elf.c | 9 +++++----
jail/jail.c | 9 +++++----
2 files changed, 10 insertions(+), 8 deletions(-)
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 <libgen.h>
#include <glob.h>
#include <elf.h>
+#include <linux/limits.h>
#include <libubox/utils.h>
@@ -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 <fcntl.h>
#include <libgen.h>
#include <sched.h>
+#include <linux/limits.h>
#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;
--
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list