diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/fortify-headers.h | 6 | ||||
| -rw-r--r-- | include/stdio.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h index 08b8dd3..24af881 100644 --- a/include/fortify-headers.h +++ b/include/fortify-headers.h | |||
| @@ -60,6 +60,12 @@ | |||
| 60 | #define __access(...) | 60 | #define __access(...) |
| 61 | #endif | 61 | #endif |
| 62 | 62 | ||
| 63 | #if defined __has_attribute && __has_attribute (format) | ||
| 64 | #define __format(...) __attribute__ ((format (__VA_ARGS__))) | ||
| 65 | #else | ||
| 66 | #define __format(...) | ||
| 67 | #endif | ||
| 68 | |||
| 63 | 69 | ||
| 64 | /* TODO(jvoisin) Figure a nice way to make use of __builtin_mul_overflow while ignoring the result. */ | 70 | /* TODO(jvoisin) Figure a nice way to make use of __builtin_mul_overflow while ignoring the result. */ |
| 65 | /* TODO(jvoisin) Make use of C23's stdckdint header: https://gustedt.gitlabpages.inria.fr/c23-library/#stdckdint */ | 71 | /* TODO(jvoisin) Make use of C23's stdckdint header: https://gustedt.gitlabpages.inria.fr/c23-library/#stdckdint */ |
diff --git a/include/stdio.h b/include/stdio.h index d5206f5..5d589f0 100644 --- a/include/stdio.h +++ b/include/stdio.h | |||
| @@ -116,6 +116,7 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, | |||
| 116 | */ | 116 | */ |
| 117 | 117 | ||
| 118 | __access(read_write, 1, 2) | 118 | __access(read_write, 1, 2) |
| 119 | __format(printf, 3, 4) | ||
| 119 | _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, | 120 | _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, |
| 120 | const char *__f, ...) | 121 | const char *__f, ...) |
| 121 | { | 122 | { |
| @@ -126,6 +127,7 @@ _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, | |||
| 126 | return __orig_snprintf(__s, __n, __f, __builtin_va_arg_pack()); | 127 | return __orig_snprintf(__s, __n, __f, __builtin_va_arg_pack()); |
| 127 | } | 128 | } |
| 128 | 129 | ||
| 130 | __format(printf, 2, 3) | ||
| 129 | _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) | 131 | _FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...) |
| 130 | { | 132 | { |
| 131 | size_t __b = __bos(__s, 0); | 133 | size_t __b = __bos(__s, 0); |
