From: Stephen Hemminger Date: Fri, 20 Apr 2018 17:38:00 +0000 (-0700) Subject: bpf: fix warnings on gcc-8 about string truncation X-Git-Tag: v4.17.0~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=260a92afe65b78cb775b36ca8fc15b03239d8b76;p=thirdparty%2Fiproute2.git bpf: fix warnings on gcc-8 about string truncation 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 --- diff --git a/lib/bpf.c b/lib/bpf.c index 04bc5a568..d9a406bf5 100644 --- 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;