ssp: switch to _limits.h for the upper bound of size_t

The definitions in _stdint.h has some complications around visibility
that _limits.h does not have.  Switch to __SIZE_T_MAX to avoid those.

This fixes the devel/gperf, devel/glib20 and math/mpfr builds with
_FORTIFY_SOURCE enabled to unlock a large fraction of the ports tree to
build.

Reported by:	Shawn Webb (HardenedBSD)
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
This commit is contained in:
Kyle Evans 2024-08-01 15:09:20 -05:00
parent 28391f188c
commit de866aa352
2 changed files with 4 additions and 4 deletions

View File

@ -87,7 +87,7 @@ __ssp_redirect_raw_impl(rtype, fun, symbol, args) { \
#define __ssp_redirect0(rtype, fun, args, call) \
__ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos0, __len)
#include <machine/_stdint.h>
#include <machine/_limits.h>
__ssp_inline int
__ssp_overlap(const void *leftp, const void *rightp, __size_t sz)
@ -96,9 +96,9 @@ __ssp_overlap(const void *leftp, const void *rightp, __size_t sz)
__uintptr_t right = (__uintptr_t)rightp;
if (left <= right)
return (SIZE_MAX - sz < left || right < left + sz);
return (__SIZE_T_MAX - sz < left || right < left + sz);
return (SIZE_MAX - sz < right || left < right + sz);
return (__SIZE_T_MAX - sz < right || left < right + sz);
}
#include <sys/_iovec.h>

View File

@ -35,7 +35,7 @@ __ssp_inline int
__ssp_wchar_overlap(const void *leftp, const void *rightp, size_t len)
{
if (len > SIZE_MAX / sizeof(wchar_t))
if (len > __SIZE_T_MAX / sizeof(wchar_t))
return (1);
return (__ssp_overlap(leftp, rightp, len * sizeof(wchar_t)));
}