From de866aa35240856bf3b0d89f253b8dc2796b11f9 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Thu, 1 Aug 2024 15:09:20 -0500 Subject: [PATCH] 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 --- include/ssp/ssp.h | 6 +++--- include/ssp/wchar.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/ssp/ssp.h b/include/ssp/ssp.h index a161df31d3d4..6856c5ce6961 100644 --- a/include/ssp/ssp.h +++ b/include/ssp/ssp.h @@ -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 +#include __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 diff --git a/include/ssp/wchar.h b/include/ssp/wchar.h index bbc84d379e56..7ed84e087f5d 100644 --- a/include/ssp/wchar.h +++ b/include/ssp/wchar.h @@ -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))); }