]> git.ipfire.org Git - thirdparty/kmod.git/commit
depmod: Fix writing over array length
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 3 Jun 2022 20:49:01 +0000 (13:49 -0700)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 27 Jun 2022 06:21:44 +0000 (23:21 -0700)
commit07bf5e1520ebf520a65f350a99d6a7f28c482ab5
tree44b62dbed49c281f43b262e3bac19a30d01948b8
parentea3c8adfd39a5f6137482daca21058132ec5ee8d
depmod: Fix writing over array length

Make sure return value in flush_stream_to() is the length written
if the value didn't the size. Fix warning on gcc 12.1:

tools/depmod.c: In function ‘output_builtin_alias_bin’:
tools/depmod.c:2465:24: warning: array subscript 4096 is above array bounds of ‘char[4096]’ [-Warray-bounds]
 2465 |                 modname[len] = '\0';
      |                 ~~~~~~~^~~~~
tools/depmod.c:2460:22: note: while referencing ‘modname’
 2460 |                 char modname[PATH_MAX];
      |                      ^~~~~~~
tools/depmod.c:2477:22: warning: array subscript 4096 is above array bounds of ‘char[4096]’ [-Warray-bounds]
 2477 |                 value[len] = '\0';
      |                 ~~~~~^~~~~
tools/depmod.c:2461:22: note: while referencing ‘value’
 2461 |                 char value[PATH_MAX];
      |                      ^~~~~

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c