commit 22bb8f49d713bd8ff464abcd731d7326030859fe
parent 3ff7b4dd70ef34fe8ccd64ebfee5d340445ac323
Author: jvoisin <julien.voisin@dustri.org>
Date: Tue, 27 Jun 2023 17:33:06 +0200
Add more access-annotations
Diffstat:
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/include/stdio.h b/include/stdio.h
@@ -47,6 +47,7 @@ _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f)
return __orig_fgets(__s, __n, __f);
}
+__access(write_only, 1)
_FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n,
size_t __m, FILE *__f)
{
@@ -59,6 +60,7 @@ _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n,
return __orig_fread(__d, __n, __m, __f);
}
+__access(read_only, 1)
_FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
size_t __m, FILE *__f)
{
@@ -71,6 +73,7 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n,
return __orig_fwrite(__d, __n, __m, __f);
}
+__access(read_write, 1, 2)
_FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n,
const char *__f, __builtin_va_list __v)
{
@@ -112,6 +115,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
*/
+__access(read_write, 1, 2)
_FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n,
const char *__f, ...)
{
diff --git a/include/string.h b/include/string.h
@@ -37,7 +37,7 @@ extern "C" {
#undef strncat
#undef strncpy
-__access(write_only, 1)
+__access(write_only, 1, 3)
__access(read_only, 2, 3)
_FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od,
const void * _FORTIFY_POS0 __os, size_t __n)
@@ -57,7 +57,7 @@ _FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od,
return __builtin_memcpy(__od, __os, __n);
}
-__access(write_only, 1)
+__access(write_only, 1, 3)
__access(read_only, 2, 3)
_FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d,
const void * _FORTIFY_POS0 __s, size_t __n)
@@ -70,7 +70,7 @@ _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d,
return __orig_memmove(__d, __s, __n);
}
-__access(write_only, 1)
+__access(write_only, 1, 3)
_FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n)
{
size_t __b = __bos(__d, 0);
diff --git a/include/strings.h b/include/strings.h
@@ -31,6 +31,8 @@ extern "C" {
|| (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
#undef bcopy
#undef bzero
+__access(write_only, 2, 3)
+__access(read_only, 1, 3)
_FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s,
void * _FORTIFY_POS0 __d, size_t __n)
{
@@ -42,6 +44,7 @@ _FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s,
return __orig_bcopy(__s, __d, __n);
}
+__access(write_only, 1, 2)
_FORTIFY_FN(bzero) void bzero(void * _FORTIFY_POS0 __s, size_t __n)
{
size_t __b = __bos(__s, 0);