Fix name space violation in fortify wrappers (bug 32052)

Rename the identifier sz to __sz everywhere.

Fixes: a643f60c53 ("Make sure that the fortified function conditionals are constant")
This commit is contained in:
Andreas Schwab 2024-08-05 10:55:51 +02:00
parent 1b0a2062c8
commit 39ca997ab3
4 changed files with 63 additions and 63 deletions

View File

@ -308,14 +308,14 @@ fgets (__fortify_clang_overload_arg (char *, __restrict, __s), int __n,
"fgets called with bigger size than length of " "fgets called with bigger size than length of "
"destination buffer") "destination buffer")
{ {
size_t sz = __glibc_objsize (__s); size_t __sz = __glibc_objsize (__s);
if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz)) if (__glibc_safe_or_unknown_len (__n, sizeof (char), __sz))
return __fgets_alias (__s, __n, __stream); return __fgets_alias (__s, __n, __stream);
#if !__fortify_use_clang #if !__fortify_use_clang
if (__glibc_unsafe_len (__n, sizeof (char), sz)) if (__glibc_unsafe_len (__n, sizeof (char), __sz))
return __fgets_chk_warn (__s, sz, __n, __stream); return __fgets_chk_warn (__s, __sz, __n, __stream);
#endif #endif
return __fgets_chk (__s, sz, __n, __stream); return __fgets_chk (__s, __sz, __n, __stream);
} }
__fortify_function __wur __nonnull ((4)) __attribute_overloadable__ size_t __fortify_function __wur __nonnull ((4)) __attribute_overloadable__ size_t
@ -326,14 +326,14 @@ fread (__fortify_clang_overload_arg (void *, __restrict, __ptr),
"fread called with bigger size * n than length " "fread called with bigger size * n than length "
"of destination buffer") "of destination buffer")
{ {
size_t sz = __glibc_objsize0 (__ptr); size_t __sz = __glibc_objsize0 (__ptr);
if (__glibc_safe_or_unknown_len (__n, __size, sz)) if (__glibc_safe_or_unknown_len (__n, __size, __sz))
return __fread_alias (__ptr, __size, __n, __stream); return __fread_alias (__ptr, __size, __n, __stream);
#if !__fortify_use_clang #if !__fortify_use_clang
if (__glibc_unsafe_len (__n, __size, sz)) if (__glibc_unsafe_len (__n, __size, __sz))
return __fread_chk_warn (__ptr, sz, __size, __n, __stream); return __fread_chk_warn (__ptr, __sz, __size, __n, __stream);
#endif #endif
return __fread_chk (__ptr, sz, __size, __n, __stream); return __fread_chk (__ptr, __sz, __size, __n, __stream);
} }
#ifdef __USE_GNU #ifdef __USE_GNU
@ -345,14 +345,14 @@ fgets_unlocked (__fortify_clang_overload_arg (char *, __restrict, __s),
"fgets called with bigger size than length of " "fgets called with bigger size than length of "
"destination buffer") "destination buffer")
{ {
size_t sz = __glibc_objsize (__s); size_t __sz = __glibc_objsize (__s);
if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz)) if (__glibc_safe_or_unknown_len (__n, sizeof (char), __sz))
return __fgets_unlocked_alias (__s, __n, __stream); return __fgets_unlocked_alias (__s, __n, __stream);
#if !__fortify_use_clang #if !__fortify_use_clang
if (__glibc_unsafe_len (__n, sizeof (char), sz)) if (__glibc_unsafe_len (__n, sizeof (char), __sz))
return __fgets_unlocked_chk_warn (__s, sz, __n, __stream); return __fgets_unlocked_chk_warn (__s, __sz, __n, __stream);
#endif #endif
return __fgets_unlocked_chk (__s, sz, __n, __stream); return __fgets_unlocked_chk (__s, __sz, __n, __stream);
} }
#endif #endif
@ -366,8 +366,8 @@ fread_unlocked (__fortify_clang_overload_arg0 (void *, __restrict, __ptr),
"fread_unlocked called with bigger size * n than " "fread_unlocked called with bigger size * n than "
"length of destination buffer") "length of destination buffer")
{ {
size_t sz = __glibc_objsize0 (__ptr); size_t __sz = __glibc_objsize0 (__ptr);
if (__glibc_safe_or_unknown_len (__n, __size, sz)) if (__glibc_safe_or_unknown_len (__n, __size, __sz))
{ {
# ifdef __USE_EXTERN_INLINES # ifdef __USE_EXTERN_INLINES
if (__builtin_constant_p (__size) if (__builtin_constant_p (__size)
@ -393,10 +393,10 @@ fread_unlocked (__fortify_clang_overload_arg0 (void *, __restrict, __ptr),
return __fread_unlocked_alias (__ptr, __size, __n, __stream); return __fread_unlocked_alias (__ptr, __size, __n, __stream);
} }
# if !__fortify_use_clang # if !__fortify_use_clang
if (__glibc_unsafe_len (__n, __size, sz)) if (__glibc_unsafe_len (__n, __size, __sz))
return __fread_unlocked_chk_warn (__ptr, sz, __size, __n, __stream); return __fread_unlocked_chk_warn (__ptr, __sz, __size, __n, __stream);
# endif # endif
return __fread_unlocked_chk (__ptr, sz, __size, __n, __stream); return __fread_unlocked_chk (__ptr, __sz, __size, __n, __stream);
} }
#endif #endif

View File

@ -37,14 +37,14 @@ recv (int __fd, __fortify_clang_overload_arg0 (void *, ,__buf), size_t __n,
"recv called with bigger length than " "recv called with bigger length than "
"size of destination buffer") "size of destination buffer")
{ {
size_t sz = __glibc_objsize0 (__buf); size_t __sz = __glibc_objsize0 (__buf);
if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz)) if (__glibc_safe_or_unknown_len (__n, sizeof (char), __sz))
return __recv_alias (__fd, __buf, __n, __flags); return __recv_alias (__fd, __buf, __n, __flags);
#if !__fortify_use_clang #if !__fortify_use_clang
if (__glibc_unsafe_len (__n, sizeof (char), sz)) if (__glibc_unsafe_len (__n, sizeof (char), __sz))
return __recv_chk_warn (__fd, __buf, __n, sz, __flags); return __recv_chk_warn (__fd, __buf, __n, __sz, __flags);
#endif #endif
return __recv_chk (__fd, __buf, __n, sz, __flags); return __recv_chk (__fd, __buf, __n, __sz, __flags);
} }
extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n, extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n,
@ -71,13 +71,13 @@ recvfrom (int __fd, __fortify_clang_overload_arg0 (void *, __restrict, __buf),
"recvfrom called with bigger length " "recvfrom called with bigger length "
"than size of destination buffer") "than size of destination buffer")
{ {
size_t sz = __glibc_objsize0 (__buf); size_t __sz = __glibc_objsize0 (__buf);
if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz)) if (__glibc_safe_or_unknown_len (__n, sizeof (char), __sz))
return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len); return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len);
#if !__fortify_use_clang #if !__fortify_use_clang
if (__glibc_unsafe_len (__n, sizeof (char), sz)) if (__glibc_unsafe_len (__n, sizeof (char), __sz))
return __recvfrom_chk_warn (__fd, __buf, __n, sz, __flags, __addr, return __recvfrom_chk_warn (__fd, __buf, __n, __sz, __flags, __addr,
__addr_len); __addr_len);
#endif #endif
return __recvfrom_chk (__fd, __buf, __n, sz, __flags, __addr, __addr_len); return __recvfrom_chk (__fd, __buf, __n, __sz, __flags, __addr, __addr_len);
} }

View File

@ -43,16 +43,16 @@ __NTH (realpath (const char *__restrict __name,
"bytes long buffer") "bytes long buffer")
#endif #endif
{ {
size_t sz = __glibc_objsize (__resolved); size_t __sz = __glibc_objsize (__resolved);
if (sz == (size_t) -1) if (__sz == (size_t) -1)
return __realpath_alias (__name, __resolved); return __realpath_alias (__name, __resolved);
#if !__fortify_use_clang && defined _LIBC_LIMITS_H_ && defined PATH_MAX #if !__fortify_use_clang && defined _LIBC_LIMITS_H_ && defined PATH_MAX
if (__glibc_unsafe_len (PATH_MAX, sizeof (char), sz)) if (__glibc_unsafe_len (PATH_MAX, sizeof (char), __sz))
return __realpath_chk_warn (__name, __resolved, sz); return __realpath_chk_warn (__name, __resolved, __sz);
#endif #endif
return __realpath_chk (__name, __resolved, sz); return __realpath_chk (__name, __resolved, __sz);
} }

View File

@ -74,9 +74,9 @@ __fortify_function __attribute_overloadable__ wchar_t *
__NTH (wcscpy (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest), __NTH (wcscpy (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
const wchar_t *__restrict __src)) const wchar_t *__restrict __src))
{ {
size_t sz = __glibc_objsize (__dest); size_t __sz = __glibc_objsize (__dest);
if (sz != (size_t) -1) if (__sz != (size_t) -1)
return __wcscpy_chk (__dest, __src, sz / sizeof (wchar_t)); return __wcscpy_chk (__dest, __src, __sz / sizeof (wchar_t));
return __wcscpy_alias (__dest, __src); return __wcscpy_alias (__dest, __src);
} }
@ -84,9 +84,9 @@ __fortify_function __attribute_overloadable__ wchar_t *
__NTH (wcpcpy (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest), __NTH (wcpcpy (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
const wchar_t *__restrict __src)) const wchar_t *__restrict __src))
{ {
size_t sz = __glibc_objsize (__dest); size_t __sz = __glibc_objsize (__dest);
if (sz != (size_t) -1) if (__sz != (size_t) -1)
return __wcpcpy_chk (__dest, __src, sz / sizeof (wchar_t)); return __wcpcpy_chk (__dest, __src, __sz / sizeof (wchar_t));
return __wcpcpy_alias (__dest, __src); return __wcpcpy_alias (__dest, __src);
} }
@ -118,9 +118,9 @@ __fortify_function __attribute_overloadable__ wchar_t *
__NTH (wcscat (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest), __NTH (wcscat (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
const wchar_t *__restrict __src)) const wchar_t *__restrict __src))
{ {
size_t sz = __glibc_objsize (__dest); size_t __sz = __glibc_objsize (__dest);
if (sz != (size_t) -1) if (__sz != (size_t) -1)
return __wcscat_chk (__dest, __src, sz / sizeof (wchar_t)); return __wcscat_chk (__dest, __src, __sz / sizeof (wchar_t));
return __wcscat_alias (__dest, __src); return __wcscat_alias (__dest, __src);
} }
@ -128,9 +128,9 @@ __fortify_function __attribute_overloadable__ wchar_t *
__NTH (wcsncat (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest), __NTH (wcsncat (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
const wchar_t *__restrict __src, size_t __n)) const wchar_t *__restrict __src, size_t __n))
{ {
size_t sz = __glibc_objsize (__dest); size_t __sz = __glibc_objsize (__dest);
if (sz != (size_t) -1) if (__sz != (size_t) -1)
return __wcsncat_chk (__dest, __src, __n, sz / sizeof (wchar_t)); return __wcsncat_chk (__dest, __src, __n, __sz / sizeof (wchar_t));
return __wcsncat_alias (__dest, __src, __n); return __wcsncat_alias (__dest, __src, __n);
} }
@ -170,10 +170,10 @@ __fortify_function int
__NTH (swprintf (wchar_t *__restrict __s, size_t __n, __NTH (swprintf (wchar_t *__restrict __s, size_t __n,
const wchar_t *__restrict __fmt, ...)) const wchar_t *__restrict __fmt, ...))
{ {
size_t sz = __glibc_objsize (__s); size_t __sz = __glibc_objsize (__s);
if (sz != (size_t) -1 || __USE_FORTIFY_LEVEL > 1) if (__sz != (size_t) -1 || __USE_FORTIFY_LEVEL > 1)
return __swprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, return __swprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
sz / sizeof (wchar_t), __fmt, __va_arg_pack ()); __sz / sizeof (wchar_t), __fmt, __va_arg_pack ());
return __swprintf_alias (__s, __n, __fmt, __va_arg_pack ()); return __swprintf_alias (__s, __n, __fmt, __va_arg_pack ());
} }
#elif __fortify_use_clang #elif __fortify_use_clang
@ -206,10 +206,10 @@ __fortify_function int
__NTH (vswprintf (wchar_t *__restrict __s, size_t __n, __NTH (vswprintf (wchar_t *__restrict __s, size_t __n,
const wchar_t *__restrict __fmt, __gnuc_va_list __ap)) const wchar_t *__restrict __fmt, __gnuc_va_list __ap))
{ {
size_t sz = __glibc_objsize (__s); size_t __sz = __glibc_objsize (__s);
if (sz != (size_t) -1 || __USE_FORTIFY_LEVEL > 1) if (__sz != (size_t) -1 || __USE_FORTIFY_LEVEL > 1)
return __vswprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, return __vswprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
sz / sizeof (wchar_t), __fmt, __ap); __sz / sizeof (wchar_t), __fmt, __ap);
return __vswprintf_alias (__s, __n, __fmt, __ap); return __vswprintf_alias (__s, __n, __fmt, __ap);
} }
@ -257,14 +257,14 @@ fgetws (__fortify_clang_overload_arg (wchar_t *, __restrict, __s), int __n,
"fgetws called with length bigger " "fgetws called with length bigger "
"than size of destination buffer") "than size of destination buffer")
{ {
size_t sz = __glibc_objsize (__s); size_t __sz = __glibc_objsize (__s);
if (__glibc_safe_or_unknown_len (__n, sizeof (wchar_t), sz)) if (__glibc_safe_or_unknown_len (__n, sizeof (wchar_t), __sz))
return __fgetws_alias (__s, __n, __stream); return __fgetws_alias (__s, __n, __stream);
#if !__fortify_use_clang #if !__fortify_use_clang
if (__glibc_unsafe_len (__n, sizeof (wchar_t), sz)) if (__glibc_unsafe_len (__n, sizeof (wchar_t), __sz))
return __fgetws_chk_warn (__s, sz / sizeof (wchar_t), __n, __stream); return __fgetws_chk_warn (__s, __sz / sizeof (wchar_t), __n, __stream);
#endif #endif
return __fgetws_chk (__s, sz / sizeof (wchar_t), __n, __stream); return __fgetws_chk (__s, __sz / sizeof (wchar_t), __n, __stream);
} }
#ifdef __USE_GNU #ifdef __USE_GNU
@ -275,15 +275,15 @@ fgetws_unlocked (__fortify_clang_overload_arg (wchar_t *, __restrict, __s),
"fgetws_unlocked called with length bigger " "fgetws_unlocked called with length bigger "
"than size of destination buffer") "than size of destination buffer")
{ {
size_t sz = __glibc_objsize (__s); size_t __sz = __glibc_objsize (__s);
if (__glibc_safe_or_unknown_len (__n, sizeof (wchar_t), sz)) if (__glibc_safe_or_unknown_len (__n, sizeof (wchar_t), __sz))
return __fgetws_unlocked_alias (__s, __n, __stream); return __fgetws_unlocked_alias (__s, __n, __stream);
# if !__fortify_use_clang # if !__fortify_use_clang
if (__glibc_unsafe_len (__n, sizeof (wchar_t), sz)) if (__glibc_unsafe_len (__n, sizeof (wchar_t), __sz))
return __fgetws_unlocked_chk_warn (__s, sz / sizeof (wchar_t), __n, return __fgetws_unlocked_chk_warn (__s, __sz / sizeof (wchar_t), __n,
__stream); __stream);
# endif # endif
return __fgetws_unlocked_chk (__s, sz / sizeof (wchar_t), __n, __stream); return __fgetws_unlocked_chk (__s, __sz / sizeof (wchar_t), __n, __stream);
} }
#endif #endif