]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c
MdeModulePkg/LzmaCustomDecompressLib: catch 4GB+ uncompressed buffer sizes
[mirror_edk2.git] / MdeModulePkg / Library / LzmaCustomDecompressLib / LzmaDecompress.c
index c58912eb6a45c21840e52ad59fd5d0a7fa3fe651..8f7c242dcaa82198e2b76718371dcb25bb3f3992 100644 (file)
@@ -127,6 +127,10 @@ GetDecodedSizeOfBuf(
                           in DestinationSize and the size of the scratch\r
                           buffer was returned in ScratchSize.\r
 \r
+  @retval RETURN_UNSUPPORTED  DestinationSize cannot be output because the\r
+                              uncompressed buffer size (in bytes) does not fit\r
+                              in a UINT32. Output parameters have not been\r
+                              modified.\r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
@@ -142,6 +146,9 @@ LzmaUefiDecompressGetInfo (
   ASSERT(SourceSize >= LZMA_HEADER_SIZE);\r
 \r
   DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);\r
+  if (DecodedSize > MAX_UINT32) {\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
 \r
   *DestinationSize = (UINT32)DecodedSize;\r
   *ScratchSize = SCRATCH_BUFFER_REQUEST_SIZE;\r