fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

commit 6f5423255b6d78b0d6979e6319642ae530f3e2b7
parent 459d202b1bbf7abb817a596ce9374edfb7b4da8f
Author: jvoisin <julien.voisin@dustri.org>
Date:   Wed, 10 Jul 2024 15:49:00 +0200

Fix `access` annotations for vsnprintf/vsprintf

This fix the following issue:

```
In file included from exec-cmd.c:9:
In function 'vsnprintf',
    inlined from 'report.constprop' at subcmd-util.h:13:2:
/usr/include/fortify/stdio.h:162:16: error: 'msg' may be used uninitialized [-Werror=maybe-uninitialized]
  162 |         return __orig_vsnprintf(__s, __n, __f, __v);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/fortify/strings.h:23,
                 from /usr/include/string.h:59,
                 from /usr/include/fortify/string.h:23,
                 from /home/ncopa/aports/main/linux-lts/src/linux-6.6/tools/include/linux/string.h:6,
                 from exec-cmd.c:3:
/usr/include/fortify/stdio.h: In function 'report.constprop':
/usr/include/fortify/stdio.h:152:1: note: in a call to '__orig_vsnprintf' declared with attribute 'access (read_write, 1, 2)' here
  152 | _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
      | ^~~~~~~~~~~
In file included from exec-cmd.c:10:
subcmd-util.h:12:14: note: 'msg' declared here
   12 |         char msg[1024];
      |              ^~~
cc1: all warnings being treated as errors
make[5]: *** [/home/ncopa/aports/main/linux-lts/src/linux-6.6/tools/build/Makefile.build:98: /home/ncopa/aports/main/linux-lts/src/build-virt.x86_64/tools/objtool/libsubcmd/exec-cmd.o] Error 1
make[4]: *** [Makefile:80: /home/ncopa/aports/main/linux-lts/src/build-virt.x86_64/tools/objtool/libsubcmd/libsubcmd-in.o] Error 2
make[3]: *** [Makefile:78: /home/ncopa/aports/main/linux-lts/src/build-virt.x86_64/tools/objtool/libsubcmd/libsubcmd.a] Error 2
make[2]: *** [Makefile:73: objtool] Error 2
make[1]: *** [/home/ncopa/aports/main/linux-lts/src/linux-6.6/Makefile:1362: tools/objtool] Error 2
make: *** [/home/ncopa/aports/main/linux-lts/src/linux-6.6/Makefile:234: __sub-make] Error 2
```

Reported-by: ncopa

Diffstat:
Minclude/stdio.h | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/stdio.h b/include/stdio.h @@ -143,7 +143,7 @@ _FORTIFY_FN(tmpfile) FILE *tmpfile(void) } #endif -__fh_access(read_write, 1, 2) +__fh_access(write_only, 1, 2) __fh_access(read_only, 3) __fh_format(printf, 3, 0) #if __has_builtin(__builtin_vsnprintf) @@ -164,7 +164,7 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, } __fh_format(printf, 2, 0) -__fh_access(read_write, 1) +__fh_access(write_only, 1) __fh_access(read_only, 2) #if __has_builtin(__builtin_vsprintf) __diagnose_as_builtin(__builtin_vsprintf, 1, 2, 3)