From e9b6cb7e2eb7029902ae92ef43fb905e5072785b Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 14 Nov 2025 15:06:23 +0100 Subject: Add `format` annotations --- include/stdio.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/stdio.h') diff --git a/include/stdio.h b/include/stdio.h index 67738ed..aebe861 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -76,6 +76,7 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, return __orig_fwrite(__d, __n, __m, __f); } +__format(printf, 3, 0) __access(write_only, 1, 2) __access(read_only, 3) _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, @@ -88,6 +89,7 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, return __orig_vsnprintf(__s, __n, __f, __v); } +__format(printf, 2, 0) __access(write_only, 1) __access(read_only, 2) _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, @@ -121,6 +123,7 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, * 3) not implementing these under clang, which is what we do for now */ +__format(printf, 3, 4) _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, const char *__f, ...) { @@ -131,6 +134,7 @@ _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, return __orig_snprintf(__s, __n, __f, __builtin_va_arg_pack()); } +__format(printf, 2, 3) _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) { size_t __b = __bos(__s, 0); -- cgit v1.3