]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bpf: fix warnings on gcc-8 about string truncation
authorStephen Hemminger <stephen@networkplumber.org>
Fri, 20 Apr 2018 17:38:00 +0000 (10:38 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 20 Apr 2018 17:38:00 +0000 (10:38 -0700)
In theory, the path for BPF could exceed the 4K PATH_MAX.
In practice, not really possible. But shut up gcc.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/bpf.c

index 04bc5a5685d546655392bcd119f3e657e28bdf94..d9a406bf55f2d4c1e26cbcffa2c4fe07f124493b 100644 (file)
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -634,7 +634,7 @@ static int bpf_gen_global(const char *bpf_sub_dir)
 
 static int bpf_gen_master(const char *base, const char *name)
 {
-       char bpf_sub_dir[PATH_MAX];
+       char bpf_sub_dir[PATH_MAX + NAME_MAX + 1];
        int ret;
 
        snprintf(bpf_sub_dir, sizeof(bpf_sub_dir), "%s%s/", base, name);
@@ -675,8 +675,8 @@ static int bpf_slave_via_bind_mnt(const char *full_name,
 static int bpf_gen_slave(const char *base, const char *name,
                         const char *link)
 {
-       char bpf_lnk_dir[PATH_MAX];
-       char bpf_sub_dir[PATH_MAX];
+       char bpf_lnk_dir[PATH_MAX + NAME_MAX + 1];
+       char bpf_sub_dir[PATH_MAX + NAME_MAX];
        struct stat sb = {};
        int ret;