From bf242b15e1f7873bdb940c2441b5e57747bc2f81 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 12 Nov 2025 22:28:13 +0100 Subject: Add `access` annotations --- include/stdio.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/stdio.h') diff --git a/include/stdio.h b/include/stdio.h index a75c9ea..67738ed 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -37,6 +37,8 @@ extern "C" { #undef snprintf #undef sprintf +__access(read_write, 1, 2) +__access(read_only, 3) _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) { size_t __b = __bos(__s, 0); @@ -46,6 +48,8 @@ _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) return __orig_fgets(__s, __n, __f); } +__access(write_only, 1) +__access(read_only, 4) _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, size_t __m, FILE *__f) { @@ -58,6 +62,8 @@ _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, return __orig_fread(__d, __n, __m, __f); } +__access(read_only, 1) +__access(write_only, 4) _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, size_t __m, FILE *__f) { @@ -70,6 +76,8 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, return __orig_fwrite(__d, __n, __m, __f); } +__access(write_only, 1, 2) +__access(read_only, 3) _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, const char *__f, __builtin_va_list __v) { @@ -80,6 +88,8 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, return __orig_vsnprintf(__s, __n, __f, __v); } +__access(write_only, 1) +__access(read_only, 2) _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, __builtin_va_list __v) { -- cgit v1.3