diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c b/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c index c58912eb6a..8f7c242dca 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c @@ -127,6 +127,10 @@ GetDecodedSizeOfBuf( in DestinationSize and the size of the scratch buffer was returned in ScratchSize. + @retval RETURN_UNSUPPORTED DestinationSize cannot be output because the + uncompressed buffer size (in bytes) does not fit + in a UINT32. Output parameters have not been + modified. **/ RETURN_STATUS EFIAPI @@ -142,6 +146,9 @@ LzmaUefiDecompressGetInfo ( ASSERT(SourceSize >= LZMA_HEADER_SIZE); DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source); + if (DecodedSize > MAX_UINT32) { + return RETURN_UNSUPPORTED; + } *DestinationSize = (UINT32)DecodedSize; *ScratchSize = SCRATCH_BUFFER_REQUEST_SIZE; diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h index 26f110ba2a..fbafd5f100 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h @@ -9,6 +9,7 @@ #ifndef __LZMADECOMPRESSLIB_INTERNAL_H__ #define __LZMADECOMPRESSLIB_INTERNAL_H__ +#include #include #include #include @@ -45,6 +46,10 @@ in DestinationSize and the size of the scratch buffer was returned in ScratchSize. + @retval RETURN_UNSUPPORTED DestinationSize cannot be output because the + uncompressed buffer size (in bytes) does not fit + in a UINT32. Output parameters have not been + modified. **/ RETURN_STATUS EFIAPI