]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/BdsLib: Prevent memory leak whith TFTP
authorOlivier Martin <olivier.martin@arm.com>
Tue, 1 Jul 2014 09:27:19 +0000 (09:27 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 1 Jul 2014 09:27:19 +0000 (09:27 +0000)
In some case, the size of the downloaded TFTP image cannot be known.
An arbitrary larger buffer is allocated to receive the image.
We need to make sure when we free the buffer we free the size
of the allocated buffer and not the size of the actual image.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15609 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/BdsLib/BdsFilePath.c

index f3fa4456555b76c8982390e4463b959826d632c0..411fcc1fcc8f810a983b76fba1e6f340a7a1a536 100644 (file)
@@ -756,6 +756,7 @@ BdsTftpLoadImage (
   EFI_STATUS                  Status;\r
   EFI_PXE_BASE_CODE_PROTOCOL  *Pxe;\r
   UINT64                      TftpBufferSize;\r
+  UINT64                      TftpTransferSize;\r
   EFI_IP_ADDRESS              ServerIp;\r
   IPv4_DEVICE_PATH*           IPv4DevicePathNode;\r
   FILEPATH_DEVICE_PATH*       FilePathDevicePath;\r
@@ -857,12 +858,13 @@ BdsTftpLoadImage (
         goto EXIT;\r
       }\r
 \r
+      TftpTransferSize = TftpBufferSize;\r
       Status = Pxe->Mtftp (\r
                       Pxe,\r
                       EFI_PXE_BASE_CODE_TFTP_READ_FILE,\r
                       (VOID *)(UINTN)*Image,\r
                       FALSE,\r
-                      &TftpBufferSize,\r
+                      &TftpTransferSize,\r
                       NULL,\r
                       &ServerIp,\r
                       (UINT8*)AsciiPathName,\r