git: de866aa35240 - main - ssp: switch to _limits.h for the upper bound of size_t

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Thu, 01 Aug 2024 20:43:19 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=de866aa35240856bf3b0d89f253b8dc2796b11f9

commit de866aa35240856bf3b0d89f253b8dc2796b11f9
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2024-08-01 20:09:20 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-08-01 20:42:17 +0000

    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 <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>
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)));
 }