]> git.proxmox.com Git - mirror_iproute2.git/commit
bpf: Fixes a snprintf truncation warning
authorAndrea Claudi <aclaudi@redhat.com>
Tue, 26 May 2020 16:04:11 +0000 (18:04 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 27 May 2020 22:05:25 +0000 (15:05 -0700)
commit354efaec3895f004382414f2df17e7d820e695f6
tree4ed009836b9040980e0dd382b4ed5719ccbbd93e
parent358abfe004a30bf3ed353c7f5dbc6afaf4212ecf
bpf: Fixes a snprintf truncation warning

gcc v9.3.1 reports:

bpf.c: In function ‘bpf_get_work_dir’:
bpf.c:784:49: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
  784 |  snprintf(bpf_wrk_dir, sizeof(bpf_wrk_dir), "%s/", mnt);
      |                                                 ^
bpf.c:784:2: note: ‘snprintf’ output between 2 and 4097 bytes into a destination of size 4096
  784 |  snprintf(bpf_wrk_dir, sizeof(bpf_wrk_dir), "%s/", mnt);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix this simply checking snprintf return code and properly handling the error.

Fixes: e42256699cac ("bpf: make tc's bpf loader generic and move into lib")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/bpf.c