]> git.ipfire.org Git - thirdparty/iproute2.git/commit
bpf: replace snprintf with asprintf when dealing with long buffers
authorAndrea Claudi <aclaudi@redhat.com>
Mon, 16 Sep 2019 13:00:55 +0000 (15:00 +0200)
committerDavid Ahern <dsahern@gmail.com>
Thu, 19 Sep 2019 14:49:46 +0000 (07:49 -0700)
commitc0325b06382cb4f7ebfaf80c29c8800d74666fd9
treea33ec9a842df07a6daf5ac0e818b4e807813b602
parent9b13cddfe26869a51329203f6866cfbb164ca951
bpf: replace snprintf with asprintf when dealing with long buffers

This reduces stack usage, as asprintf allocates memory on the heap.

This indirectly fixes a snprintf truncation warning (from gcc v9.2.1):

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);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: e42256699cac ("bpf: make tc's bpf loader generic and move into lib")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
lib/bpf.c