diff options
| author | Doug Cook <dcook@microsoft.com> | 2026-08-16 03:10:46 +0300 |
|---|---|---|
| committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2026-08-31 15:55:20 +0300 |
| commit | ba43de142c8e9fde9ad2ef4b2fcd1a525e494968 (patch) | |
| tree | 89ed6303cfe63e63d54a01bb5091cf6be164a595 /MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c | |
| parent | c5745468c419daeab57c0cfef1a5e077528be5f3 (diff) | |
| download | edk2-ba43de142c8e9fde9ad2ef4b2fcd1a525e494968.tar.xz | |
CryptoPkg: Fix SIZE_MAX, UINTPTR_MAX and intptr_t definitions
CrtLibSupport.h defines SIZE_MAX and UINTPTR_MAX as 32-bit constants on
every target, even though the types they describe (size_t, uintptr_t) are
typedefs of UINTN and so are 64-bit on X64, AARCH64, IA64, RISCV64 and
LOONGARCH64.
UINTPTR_MAX definition was controlled by "#if (UINT_MAX > 0xFFFFFFFFUL)",
which can never be true, so it was always set to UINT32_MAX.
Fix cannot just use MAX_UINTN because that isn't usable in preprocessor
conditions. Instead, define SIZE_MAX and UINTPTR_MAX based on CPU.
Without this, CryptoPkgMbedTls.dsc fails to build for AArch64:
library/constant_time.c:58:5: error: invalid 'asm': invalid operand
In addition, the wrong SIZE_MAX silently removes length-overflow checks
that MbedTLS guards with "#if SIZE_MAX > UINT_MAX", including the ASN.1
length check in asn1write.c and the input length check in nist_kw.c, and
selects 32-bit constant-time helper types in constant_time_internal.h.
Also correct intptr_t, which was a typedef of the unsigned UINTN. The
neighbouring ptrdiff_t and ssize_t already use INTN.
TcgTpmPkg/Private/Include/Standard/CrtLibSupport.h is a byte-identical
copy of this header and has the same defects. It is fixed by a separate
patch so that each commit stays within a single package.
Tested by building CryptoPkg/CryptoPkgMbedTls.dsc with GCC for AARCH64,
X64 and IA32. AARCH64 does not build without this change; X64 and IA32
are unaffected.
Signed-off-by: Doug Cook <dcook@microsoft.com>
Diffstat (limited to 'MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c')
0 files changed, 0 insertions, 0 deletions
