summaryrefslogtreecommitdiff
path: root/include/stdio.h
diff options
context:
space:
mode:
authorjvoisin2023-07-09 19:14:44 +0200
committerjvoisin2023-07-09 19:14:44 +0200
commite7c10a1b27be94a09bb03bf31b4b66233e3d1bdc (patch)
tree74eaf63f04fa673d81fe900f38dbae1b1241fefe /include/stdio.h
parentb333df29dcfabcd4ad0cf630fdb648eaa38ec1c7 (diff)
Add some malloc annotations
Diffstat (limited to 'include/stdio.h')
-rw-r--r--include/stdio.h42
1 files changed, 40 insertions, 2 deletions
diff --git a/include/stdio.h b/include/stdio.h
index 5d589f0..8cdd826 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -29,13 +29,25 @@ __extension__
29extern "C" { 29extern "C" {
30#endif 30#endif
31 31
32#undef fdopen
32#undef fgets 33#undef fgets
34#undef fmemopen
35#undef fopen
33#undef fread 36#undef fread
34#undef fwrite 37#undef fwrite
35#undef vsprintf 38#undef popen
36#undef vsnprintf 39#undef tmpfile
37#undef snprintf 40#undef snprintf
38#undef sprintf 41#undef sprintf
42#undef vsnprintf
43#undef vsprintf
44
45__access(read_only, 2)
46__malloc(malloc (fclose, 1))
47_FORTIFY_FN(fdopen) FILE *fdopen(int __f, const char* __m)
48{
49 return __orig_fdopen(__f, __m);
50}
39 51
40__access(write_only, 1, 2) 52__access(write_only, 1, 2)
41_FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) 53_FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f)
@@ -47,6 +59,20 @@ _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f)
47 return __orig_fgets(__s, __n, __f); 59 return __orig_fgets(__s, __n, __f);
48} 60}
49 61
62__malloc(malloc (fclose, 1))
63_FORTIFY_FN(fmemopen) FILE *fmemopen(void* __b, size_t __s, const char* __m)
64{
65 return __orig_fmemopen(__b, __s, __m);
66}
67
68__access(read_only, 1)
69__access(read_only, 2)
70__malloc(malloc (fclose, 1))
71_FORTIFY_FN(fopen) FILE *fopen(const char* __p, const char* __m)
72{
73 return __orig_fopen(__p, __m);
74}
75
50__access(write_only, 1) 76__access(write_only, 1)
51_FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, 77_FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n,
52 size_t __m, FILE *__f) 78 size_t __m, FILE *__f)
@@ -73,6 +99,18 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
73 return __orig_fwrite(__d, __n, __m, __f); 99 return __orig_fwrite(__d, __n, __m, __f);
74} 100}
75 101
102__malloc(malloc (pclose, 1))
103_FORTIFY_FN(popen) FILE *popen(const char* __c, const char* __t)
104{
105 return __orig_popen(__c, __t);
106}
107
108__malloc(malloc (fclose, 1))
109_FORTIFY_FN(tmpfile) FILE *tmpfile(void)
110{
111 return __orig_tmpfile();
112}
113
76__access(read_write, 1, 2) 114__access(read_write, 1, 2)
77_FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, 115_FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
78 const char *__f, __builtin_va_list __v) 116 const char *__f, __builtin_va_list __v)