Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread GN Keshava
Thanks for the help, Michael.. Yes, I'm running the app from shell (at
least for now).. I will try your suggestion.

Thanks again.
Regards,
Keshava

On Thu, 13 Oct 2016 at 11:50 Michael Zimmermann 
wrote:

> > Is it possible to run RM (or any shell command) from my C application
> code?
> > Something like "System()" in Linux? Whether we can use LoadImage for
> this
> > purpose?
> If you application was started from the Shell you can do that
> using ShellExecute from 'Library/ShellLib.h'. Example:
>
> EFI_STATUS Status;
> EFI_STATUS CommandStatus;
> Status = ShellExecute (&gImageHandle, L"memmap", FALSE, NULL,
> &CommandStatus);
>
> If you were not started by the Shell you can run a new Shell and tell it
> to run your command and exit afterwards using these LoadImage arguments:
>
> -nomap -nostartup -noversion -_exit [CMD OR FILE]
>
> Thanks
> Michael
>
> On Thu, Oct 13, 2016 at 3:29 AM, GN Keshava  wrote:
>
> Thanks Laszlo.
>
> Is it possible to run RM (or any shell command) from my C application code?
> Something like "System()" in Linux? Whether we can use LoadImage for this
> purpose?
>
> Thanks again.
> Regards,
> Keshava
>
>
> On Wed 12 Oct, 2016 11:10 pm Laszlo Ersek,  wrote:
>
> > On 10/12/16 19:34, GN Keshava wrote:
> > > Thanks Laszlo, I'll check it out.
> > >
> > > I think I need to combine the LS implementation and RM implementation,
> > > isn't it? So there is no "format this volume" function or command
> > > exists, right?
> >
> > I'm unaware of any "format" command. And, I think it's enough if you
> > look at RM (LS should be unnecessary); RM already contains the recursion.
> >
> > Laszlo
> >
> >
>
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>
>
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread Michael Zimmermann
> Is it possible to run RM (or any shell command) from my C application
code?
> Something like "System()" in Linux? Whether we can use LoadImage for this
> purpose?
If you application was started from the Shell you can do that
using ShellExecute from 'Library/ShellLib.h'. Example:

EFI_STATUS Status;
EFI_STATUS CommandStatus;
Status = ShellExecute (&gImageHandle, L"memmap", FALSE, NULL,
&CommandStatus);

If you were not started by the Shell you can run a new Shell and tell it to
run your command and exit afterwards using these LoadImage arguments:

-nomap -nostartup -noversion -_exit [CMD OR FILE]

Thanks
Michael

On Thu, Oct 13, 2016 at 3:29 AM, GN Keshava  wrote:

> Thanks Laszlo.
>
> Is it possible to run RM (or any shell command) from my C application code?
> Something like "System()" in Linux? Whether we can use LoadImage for this
> purpose?
>
> Thanks again.
> Regards,
> Keshava
>
> On Wed 12 Oct, 2016 11:10 pm Laszlo Ersek,  wrote:
>
> > On 10/12/16 19:34, GN Keshava wrote:
> > > Thanks Laszlo, I'll check it out.
> > >
> > > I think I need to combine the LS implementation and RM implementation,
> > > isn't it? So there is no "format this volume" function or command
> > > exists, right?
> >
> > I'm unaware of any "format" command. And, I think it's enough if you
> > look at RM (LS should be unnecessary); RM already contains the recursion.
> >
> > Laszlo
> >
> >
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] IntelFsp2Pkg/FspSecCore: Make FSP funcitons position independent

2016-10-12 Thread Ma, Maurice
Hi, Giri,

Sure, I'll fix the typo.  Thank you for the review!

-Maurice

-Original Message-
From: Mudusuru, Giri P 
Sent: Wednesday, October 12, 2016 6:56 PM
To: Ma, Maurice; edk2-devel@lists.01.org
Cc: Yao, Jiewen
Subject: RE: [edk2] [PATCH] IntelFsp2Pkg/FspSecCore: Make FSP funcitons 
position independent

Thanks for fixing the bug Maurice. Please fix the typo funcitons in the title 
during checkin

Reviewed-by: Giri P Mudusuru  

> -Original Message-
> From: Ma, Maurice
> Sent: Wednesday, October 12, 2016 6:03 PM
> To: edk2-devel@lists.01.org
> Cc: Ma, Maurice ; Yao, Jiewen 
> ; Mudusuru, Giri P 
> Subject: [edk2] [PATCH] IntelFsp2Pkg/FspSecCore: Make FSP funcitons 
> position independent
> 
> The current AsmGetFspInfoHeader function in FspHeader.nasm is position 
> dependent code since it uses absolute address. Change to use relative 
> address instead to make it position independent.
> 
> Cc: Jiewen Yao 
> Cc: Giri P Mudusuru 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Maurice Ma 
> ---
>  IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
> b/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
> index a848dcbc0298..ad631943e32d 100644
> --- a/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
> +++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
> @@ -31,7 +31,7 @@ ASM_PFX(NextInstruction):
> pop   eax
> sub   eax, ASM_PFX(NextInstruction)
> add   eax, ASM_PFX(AsmGetFspInfoHeader)
> -   sub   eax, dword [ASM_PFX(FspInfoHeaderRelativeOff)]
> +   sub   eax, dword [eax - ASM_PFX(AsmGetFspInfoHeader) +
> ASM_PFX(FspInfoHeaderRelativeOff)]
> ret
> 
>  global ASM_PFX(AsmGetFspInfoHeaderNoStack)
> --
> 1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] SmmCommunicationCommunicate question?

2016-10-12 Thread Anbazhagan, Baraneedharan
Whether TPL needs to be raised before setting CommunicationBuffer and 
BufferSize in gSmmCorePrivate to avoid a callback overwriting those values 
before triggering SW SMI?

-Baranee
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] IntelSiliconPkg: Add Intel Firmware Version Info (FVI) definitions

2016-10-12 Thread Giri P Mudusuru
Adding Intel Firmware Version Info (FVI) related defines & structures.
FVI enables reporting the Firmware Versions using SMBIOS OEM Type.

Cc: Jiewen Yao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Giri P Mudusuru 
---
 .../Include/IndustryStandard/FirmwareVersionInfo.h | 60 ++
 1 file changed, 60 insertions(+)
 create mode 100644 
IntelSiliconPkg/Include/IndustryStandard/FirmwareVersionInfo.h

diff --git a/IntelSiliconPkg/Include/IndustryStandard/FirmwareVersionInfo.h 
b/IntelSiliconPkg/Include/IndustryStandard/FirmwareVersionInfo.h
new file mode 100644
index 000..4ac5e27
--- /dev/null
+++ b/IntelSiliconPkg/Include/IndustryStandard/FirmwareVersionInfo.h
@@ -0,0 +1,60 @@
+/** @file
+  Intel Firmware Version Info (FVI) related definitions.
+
+  @todo: update document/spec reference
+
+  Copyright (c) 2016, Intel Corporation. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+@par Specification Reference:
+  System Management BIOS (SMBIOS) Reference Specification v3.0.0 dated 
2015-Feb-12
+  http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
+
+**/
+
+#ifndef __FIRMWARE_VERSION_INFO_H__
+#define __FIRMWARE_VERSION_INFO_H__
+
+#include SmBios.h
+
+#define INTEL_FIRMWARE_VERSION_INFO_GROUP_NAME"Firmware Version Info"
+
+#pragma pack(1)
+
+///
+/// Firmware Version Structure
+///
+typedef struct {
+  UINT8   MajorVersion;
+  UINT8   MinorVersion;
+  UINT8   Revision;
+  UINT16  BuildNumber;
+} INTEL_FIRMWARE_VERSION;
+
+///
+/// Firmware Version Info (FVI) Structure
+///
+typedef struct {
+  SMBIOS_TABLE_STRING ComponentName;  ///< String Index of Component 
Name
+  SMBIOS_TABLE_STRING VersionString;  ///< String Index of Version 
String
+  INTEL_FIRMWARE_VERSION  Version;///< Firmware version
+} INTEL_FIRMWARE_VERSION_INFO;
+
+///
+/// SMBIOS OEM Type Intel Firmware Version Info (FVI) Structure
+///
+typedef struct {
+  SMBIOS_STRUCTUREHeader; ///< SMBIOS structure header
+  UINT8   Count;  ///< Number of FVI entries in 
this structure
+  INTEL_FIRMWARE_VERSION_INFO Fvi[1]; ///< FVI structure(s)
+} SMBIOS_TABLE_TYPE_OEM_INTEL_FVI;
+
+#pragma pack()
+
+#endif
-- 
2.9.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] IntelFsp2Pkg/FspSecCore: Make FSP funcitons position independent

2016-10-12 Thread Mudusuru, Giri P
Thanks for fixing the bug Maurice. Please fix the typo funcitons in the title 
during checkin

Reviewed-by: Giri P Mudusuru  

> -Original Message-
> From: Ma, Maurice
> Sent: Wednesday, October 12, 2016 6:03 PM
> To: edk2-devel@lists.01.org
> Cc: Ma, Maurice ; Yao, Jiewen
> ; Mudusuru, Giri P 
> Subject: [edk2] [PATCH] IntelFsp2Pkg/FspSecCore: Make FSP funcitons position
> independent
> 
> The current AsmGetFspInfoHeader function in FspHeader.nasm is
> position dependent code since it uses absolute address. Change
> to use relative address instead to make it position independent.
> 
> Cc: Jiewen Yao 
> Cc: Giri P Mudusuru 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Maurice Ma 
> ---
>  IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
> b/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
> index a848dcbc0298..ad631943e32d 100644
> --- a/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
> +++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
> @@ -31,7 +31,7 @@ ASM_PFX(NextInstruction):
> pop   eax
> sub   eax, ASM_PFX(NextInstruction)
> add   eax, ASM_PFX(AsmGetFspInfoHeader)
> -   sub   eax, dword [ASM_PFX(FspInfoHeaderRelativeOff)]
> +   sub   eax, dword [eax - ASM_PFX(AsmGetFspInfoHeader) +
> ASM_PFX(FspInfoHeaderRelativeOff)]
> ret
> 
>  global ASM_PFX(AsmGetFspInfoHeaderNoStack)
> --
> 1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 00/11] Remove unnecessary EFIAPI

2016-10-12 Thread Ni, Ruiyu
I actually off-line reviewed the 11 patches before sending them out.

Reviewed-by: Ruiyu Ni 

Regards,
Ray

>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ruiyu Ni
>Sent: Friday, September 30, 2016 4:18 PM
>To: edk2-devel@lists.01.org
>Subject: [edk2] [PATCH 00/11] Remove unnecessary EFIAPI
>
>Many Shell internal functions have EFIAPI modifier.
>But it's not necessary. The patch serials remove the unnecessary
>EFIAPI.
>
>Ruiyu Ni (11):
>  ShellPkg/Shell: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellDebug1CommandsLib: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellDriver1CommandsLib: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellLevel1CommandsLib: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellLevel2CommandsLib: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellLevel3CommandsLib: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellParsingLib: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellBcfgCommandLib: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellCommandLib: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellLib: Remove unnecessary EFIAPI
>  ShellPkg/UefiShellNetwork1CommandsLib: Remove unnecessary EFIAPI
>
> ShellPkg/Application/Shell/ConsoleLogger.c | 10 -
> ShellPkg/Application/Shell/ConsoleLogger.h |  6 ---
> ShellPkg/Application/Shell/ConsoleWrappers.c   |  4 --
> ShellPkg/Application/Shell/ConsoleWrappers.h   |  4 --
> ShellPkg/Application/Shell/FileHandleInternal.h|  3 --
> ShellPkg/Application/Shell/FileHandleWrappers.c|  6 ---
> ShellPkg/Application/Shell/FileHandleWrappers.h|  2 -
> ShellPkg/Application/Shell/Shell.c | 36 -
> ShellPkg/Application/Shell/Shell.h | 16 
> ShellPkg/Application/Shell/ShellEnvVar.c   |  4 --
> ShellPkg/Application/Shell/ShellEnvVar.h   |  4 --
> ShellPkg/Application/Shell/ShellManParser.c|  9 -
> ShellPkg/Application/Shell/ShellManParser.h|  2 -
> .../Application/Shell/ShellParametersProtocol.c| 14 ---
> .../Application/Shell/ShellParametersProtocol.h|  8 
> ShellPkg/Application/Shell/ShellProtocol.c | 25 ++--
> ShellPkg/Application/Shell/ShellProtocol.h |  9 -
> .../UefiHandleParsingLib/UefiHandleParsingLib.c|  6 ---
> .../UefiShellBcfgCommandLib.c  |  9 -
> .../Library/UefiShellCommandLib/ConsistMapping.c   |  3 --
> .../UefiShellCommandLib/UefiShellCommandLib.c  |  6 ---
> .../Library/UefiShellDebug1CommandsLib/Compress.c  | 30 ---
> ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c |  1 -
> ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c |  2 -
> .../Library/UefiShellDebug1CommandsLib/DmpStore.c  |  3 --
> .../UefiShellDebug1CommandsLib/Edit/FileBuffer.c   | 45 --
> .../UefiShellDebug1CommandsLib/Edit/FileBuffer.h   | 17 
> .../Edit/MainTextEditor.c  |  9 -
> .../Edit/MainTextEditor.h  |  5 ---
> .../Library/UefiShellDebug1CommandsLib/Edit/Misc.c |  2 -
> .../Library/UefiShellDebug1CommandsLib/Edit/Misc.h |  2 -
> .../UefiShellDebug1CommandsLib/EditInputBar.c  |  7 
> .../UefiShellDebug1CommandsLib/EditInputBar.h  |  6 ---
> .../UefiShellDebug1CommandsLib/EditMenuBar.c   |  6 ---
> .../UefiShellDebug1CommandsLib/EditMenuBar.h   |  6 ---
> .../UefiShellDebug1CommandsLib/EditStatusBar.c |  7 
> .../UefiShellDebug1CommandsLib/EditStatusBar.h |  7 
> .../UefiShellDebug1CommandsLib/EditTitleBar.c  |  3 --
> .../UefiShellDebug1CommandsLib/EditTitleBar.h  |  3 --
> .../HexEdit/BufferImage.c  |  9 -
> .../HexEdit/BufferImage.h  |  4 --
> .../UefiShellDebug1CommandsLib/HexEdit/DiskImage.c |  1 -
> .../HexEdit/MainHexEditor.c|  1 -
> .../HexEdit/MainHexEditor.h|  1 -
> .../UefiShellDebug1CommandsLib/LoadPciRom.c|  2 -
> ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c   |  1 -
> ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c  | 18 -
> .../Library/UefiShellDebug1CommandsLib/SerMode.c   |  1 -
> .../Library/UefiShellDebug1CommandsLib/SetVar.c|  1 -
> .../SmbiosView/EventLogInfo.c  |  5 ---
> .../SmbiosView/EventLogInfo.h  |  5 ---
> .../SmbiosView/SmbiosView.c|  8 
> .../SmbiosView/SmbiosView.h|  7 
> .../UefiShellDebug1CommandsLib.c   |  9 -
> .../UefiShellDebug1CommandsLib.h   |  7 
> .../Library/UefiShellDriver1CommandsLib/Connect.c  |  3 --
> .../Library/UefiShellDriver1CommandsLib/DevTree.c  |  1 -
> .../Library/UefiShellDriver1CommandsLib/Devices.c  |  1 -
> ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c  |  9 -
> .../UefiShellDriver1CommandsLib/Disconnect.c   |  1 -
> .../Library/UefiShellDriver1CommandsLib/Drivers.c  

Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread GN Keshava
Thanks Laszlo.

Is it possible to run RM (or any shell command) from my C application code?
Something like "System()" in Linux? Whether we can use LoadImage for this
purpose?

Thanks again.
Regards,
Keshava

On Wed 12 Oct, 2016 11:10 pm Laszlo Ersek,  wrote:

> On 10/12/16 19:34, GN Keshava wrote:
> > Thanks Laszlo, I'll check it out.
> >
> > I think I need to combine the LS implementation and RM implementation,
> > isn't it? So there is no "format this volume" function or command
> > exists, right?
>
> I'm unaware of any "format" command. And, I think it's enough if you
> look at RM (LS should be unnecessary); RM already contains the recursion.
>
> Laszlo
>
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 17/45] MdeModulePkg/CapsuleApp: Add CapsuleApp application.

2016-10-12 Thread Yao, Jiewen
Sounds good! Thanks to confirm that.

From: Carsey, Jaben
Sent: Thursday, October 13, 2016 5:04 AM
To: Yao, Jiewen ; Ni, Ruiyu ; 
Rothman, Michael A ; Kinney, Michael D 
; 'edk2-devel@lists.01.org' 

Cc: Tian, Feng ; Zhang, Chao B ; 
Gao, Liming ; Zeng, Star ; Carsey, 
Jaben 
Subject: RE: [PATCH 17/45] MdeModulePkg/CapsuleApp: Add CapsuleApp application.

I agree.

We should move the 3 protocols from the UEFI Shell Specification from ShellPkg 
to MdePkg.

I think that this is a non-backwards-compatible-change and will require a new 
GUID in ShellPkg.

-Jaben

From: Yao, Jiewen
Sent: Tuesday, October 11, 2016 7:45 AM
To: Ni, Ruiyu mailto:ruiyu...@intel.com>>; Carsey, Jaben 
mailto:jaben.car...@intel.com>>; Rothman, Michael A 
mailto:michael.a.roth...@intel.com>>; Kinney, 
Michael D mailto:michael.d.kin...@intel.com>>; 
'edk2-devel@lists.01.org' 
mailto:edk2-devel@lists.01.org>>
Cc: Tian, Feng mailto:feng.t...@intel.com>>; Zhang, Chao B 
mailto:chao.b.zh...@intel.com>>; Gao, Liming 
mailto:liming@intel.com>>; Zeng, Star 
mailto:star.z...@intel.com>>
Subject: RE: [PATCH 17/45] MdeModulePkg/CapsuleApp: Add CapsuleApp application.
Importance: High

Yes, I think that is a very good idea.

Shell spec defines EFI_SHELL_PROTOCOL, EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL, 
EFI_SHELL_PARAMETERS_PROTOCOL.
These should be treated as industry stand and we can move these 3 to MdePkg.

SHELL_ENVIRONMENT_2_PROTOCOL and SHELL_INTERFACE_PROTOCOL should be still in 
ShellPkg, since it is not standard.

Thank you
Yao Jiewen


From: Ni, Ruiyu
Sent: Tuesday, October 11, 2016 4:28 PM
To: Carsey, Jaben mailto:jaben.car...@intel.com>>; 
Rothman, Michael A 
mailto:michael.a.roth...@intel.com>>; Yao, Jiewen 
mailto:jiewen@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 
'edk2-devel@lists.01.org' 
mailto:edk2-devel@lists.01.org>>
Cc: Tian, Feng mailto:feng.t...@intel.com>>; Zhang, Chao B 
mailto:chao.b.zh...@intel.com>>; Gao, Liming 
mailto:liming@intel.com>>; Zeng, Star 
mailto:star.z...@intel.com>>
Subject: RE: [PATCH 17/45] MdeModulePkg/CapsuleApp: Add CapsuleApp application.

Jaben,
The reason I propose to move the Shell protocol definitions to MdePkg is that 
all applications that wants to use the ARGV can use the ShellParameter 
protocol, without depending on ShellPkg.

Thanks/Ray

From: Ni, Ruiyu
Sent: Tuesday, October 11, 2016 4:08 PM
To: Carsey, Jaben mailto:jaben.car...@intel.com>>; 
Rothman, Michael A 
mailto:michael.a.roth...@intel.com>>; Yao, Jiewen 
mailto:jiewen@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 
edk2-devel@lists.01.org
Cc: Tian, Feng mailto:feng.t...@intel.com>>; Zhang, Chao B 
mailto:chao.b.zh...@intel.com>>; Gao, Liming 
mailto:liming@intel.com>>; Zeng, Star 
mailto:star.z...@intel.com>>
Subject: RE: [PATCH 17/45] MdeModulePkg/CapsuleApp: Add CapsuleApp application.

Jaben,
How about moving the contents in ShellPkg\Include\Protocol\ to 
MdePkg\Include\Protocol\?
All industry standard protocols are defined in MdePkg, except the Shell related 
protocols.

Thanks/Ray
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] IntelFsp2Pkg/FspSecCore: Make FSP funcitons position independent

2016-10-12 Thread Maurice Ma
The current AsmGetFspInfoHeader function in FspHeader.nasm is
position dependent code since it uses absolute address. Change
to use relative address instead to make it position independent.

Cc: Jiewen Yao 
Cc: Giri P Mudusuru 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Maurice Ma 
---
 IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
index a848dcbc0298..ad631943e32d 100644
--- a/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspHelper.nasm
@@ -31,7 +31,7 @@ ASM_PFX(NextInstruction):
pop   eax
sub   eax, ASM_PFX(NextInstruction)
add   eax, ASM_PFX(AsmGetFspInfoHeader)
-   sub   eax, dword [ASM_PFX(FspInfoHeaderRelativeOff)]
+   sub   eax, dword [eax - ASM_PFX(AsmGetFspInfoHeader) + 
ASM_PFX(FspInfoHeaderRelativeOff)]
ret
 
 global ASM_PFX(AsmGetFspInfoHeaderNoStack)
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch] Nt32Pkg SecMain: Update SecMain.inf to support VS2015x86 X64 Mode

2016-10-12 Thread Liming Gao
From: chanuei 

Update SecMain.inf to support VS2015x86 X64 Mode Build.
After this change, X64 Native Tools Command Prompt is not
required to be trig. NT32 IA32 and X64 can be built in the same
environment. It simplifies NT32 X64 build. New build command:
edksetup.bat --nt32
build -p Nt32Pkg\Nt32Pkg.dsc -a X64  # for 64
build -p Nt32Pkg\Nt32Pkg.dsc -a IA32 # for 32

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Chan 
Tested-by: Liming Gao 
---
 Nt32Pkg/Sec/SecMain.inf | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Nt32Pkg/Sec/SecMain.inf b/Nt32Pkg/Sec/SecMain.inf
index 01bde2e..d6426c7 100644
--- a/Nt32Pkg/Sec/SecMain.inf
+++ b/Nt32Pkg/Sec/SecMain.inf
@@ -75,9 +75,9 @@
   MSFT:*_*_IA32_ASM_FLAGS == /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi
   MSFT:*_*_IA32_ASMLINK_FLAGS   == /link /nologo /tiny
 
-  MSFT:*_*_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x1000 
/pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" 
/LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib\AMD64" /NOLOGO /SUBSYSTEM:CONSOLE 
/NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG 
Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib
-  MSFT:*_VS2015_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" 
/base:0x1000 /pdb:"$(BIN_DIR)\SecMain.pdb" 
/LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" 
/LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib\AMD64" /NOLOGO /SUBSYSTEM:CONSOLE 
/NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG 
Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib 
Winmm.lib Advapi32.lib
-  MSFT:*_VS2015x86_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" 
/base:0x1000 /pdb:"$(BIN_DIR)\SecMain.pdb" 
/LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" 
/LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib\AMD64" /NOLOGO /SUBSYSTEM:CONSOLE 
/NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG 
Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib 
Winmm.lib Advapi32.lib
+  MSFT:*_*_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" /base:0x1000 
/pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" 
/LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" 
/LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\um\x64" 
/LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO 
/SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG 
/MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib 
Advapi32.lib
+  MSFT:*_VS2015_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" 
/base:0x1000 /pdb:"$(BIN_DIR)\SecMain.pdb" 
/LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" 
/LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" 
/LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\um\x64" 
/LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO 
/SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG 
/MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib 
Gdi32.lib User32.lib Winmm.lib Advapi32.lib
+  MSFT:*_VS2015x86_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\SecMain.exe" 
/base:0x1000 /pdb:"$(BIN_DIR)\SecMain.pdb" 
/LIBPATH:"$(VCINSTALLDIR)\Lib\AMD64" 
/LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" 
/LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\um\x64" 
/LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO 
/SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG 
/MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib 
Gdi32.lib User32.lib Winmm.lib Advapi32.lib
   MSFT:*_*_X64_CC_FLAGS == /nologo /W4 /WX /Gy /c /D UNICODE /Od /FIAutoGen.h 
/EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D 
_CRT_SECURE_NO_DEPRECATE
   MSFT:*_*_X64_PP_FLAGS == /nologo /E /TC /FIAutoGen.h
   MSFT:*_*_X64_ASM_FLAGS == /nologo /W3 /WX /c /Cx /Zd /W0 /Zi
-- 
2.8.0.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] [edk2-staging/HTTPS-TLS][PATCH]: CryptoPkg/TlsLib: Fix FILE_GUID

2016-10-12 Thread Wu, Jiaxin
Reviewed-By: Wu Jiaxin 

Best Regards!
Jiaxin

> -Original Message-
> From: Thomas Palmer [mailto:thomas.pal...@hpe.com]
> Sent: Thursday, October 13, 2016 4:43 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin ; joseph.shiffl...@hpe.com; Thomas
> Palmer 
> Subject: [PATCH] [edk2-staging/HTTPS-TLS][PATCH]: CryptoPkg/TlsLib: Fix
> FILE_GUID
> 
> TlsLib's FILE_GUID is a duplicate of BaseCryptLib. Use a new unique guid
> instead
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Thomas Palmer 
> ---
>  CryptoPkg/Library/TlsLib/TlsLib.inf | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/CryptoPkg/Library/TlsLib/TlsLib.inf
> b/CryptoPkg/Library/TlsLib/TlsLib.inf
> index 6194e95..823e159 100644
> --- a/CryptoPkg/Library/TlsLib/TlsLib.inf
> +++ b/CryptoPkg/Library/TlsLib/TlsLib.inf
> @@ -2,6 +2,7 @@
>  #  SSL/TLS Wrapper Library Instance based on OpenSSL.
>  #
>  #  Copyright (c) 2016, Intel Corporation. All rights reserved.
> +#  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
>  #  This program and the accompanying materials  #  are licensed and made
> available under the terms and conditions of the BSD License  #  which
> accompanies this distribution.  The full text of the license may be found at 
> @@
> -16,7 +17,7 @@
>INF_VERSION= 0x00010005
>BASE_NAME  = TlsLib
>MODULE_UNI_FILE= TlsLib.uni
> -  FILE_GUID  = be3bb803-91b6-4da0-bd91-a8b21c18ca5d
> +  FILE_GUID  = CC729DC5-4E21-0B36-1A00-3A8E1B86A155
>MODULE_TYPE= DXE_DRIVER
>VERSION_STRING = 1.0
>LIBRARY_CLASS  = TlsLib|DXE_DRIVER DXE_CORE
> UEFI_APPLICATION UEFI_DRIVER
> @@ -43,4 +44,4 @@
>OpensslLib
>IntrinsicLib
>PrintLib
> -  OpensslTlsLib
> \ No newline at end of file
> +  OpensslTlsLib
> --
> 2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation DSC/FDF.

2016-10-12 Thread Yao, Jiewen
Sounds great!

From: Gao, Liming
Sent: Thursday, October 13, 2016 8:44 AM
To: Yao, Jiewen ; Kinney, Michael D 
; edk2-devel@lists.01.org
Cc: Steele, Kelly ; Tian, Feng ; 
Zeng, Star ; Zhang, Chao B ; Gao, 
Liming 
Subject: RE: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
DSC/FDF.

Jiewen:
  The latest BaseTools Win32 Binary has supported it. Please try.

From: Yao, Jiewen
Sent: Thursday, October 13, 2016 8:39 AM
To: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 
edk2-devel@lists.01.org
Cc: Steele, Kelly mailto:kelly.ste...@intel.com>>; 
Tian, Feng mailto:feng.t...@intel.com>>; Zeng, Star 
mailto:star.z...@intel.com>>; Gao, Liming 
mailto:liming@intel.com>>; Zhang, Chao B 
mailto:chao.b.zh...@intel.com>>
Subject: RE: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
DSC/FDF.

Yes. I will do that once BaseTool binary is updated.

From: Kinney, Michael D
Sent: Thursday, October 13, 2016 5:01 AM
To: Yao, Jiewen mailto:jiewen@intel.com>>; 
edk2-devel@lists.01.org; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Cc: Steele, Kelly mailto:kelly.ste...@intel.com>>; 
Tian, Feng mailto:feng.t...@intel.com>>; Zeng, Star 
mailto:star.z...@intel.com>>; Gao, Liming 
mailto:liming@intel.com>>; Zhang, Chao B 
mailto:chao.b.zh...@intel.com>>
Subject: RE: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
DSC/FDF.

Jiewen,

Please remove the QuarkCapsule.fdf file and merge those contents into Quark.fdf.

In Quark.fdf, put the FMP and Capsules sections for recovery next to each other
surrounded by !if $(RECOVERY_ENABLE).  With the update to GenFds in BaseTools,
the order of the sections is more flexible, so you can now put the related
sections next to each other in the FDF.

In Quark.fdf, put the FMP and Capsules sections for firmware update next to each
Other surrounded by !if $(CAPSULE_ENABLE).  With the update to GenFds in 
BaseTools,
the order of the sections is more flexible, so you can now put the related
sections next to each other in the FDF.

In Quark.dsc, set PcdRecoveryFileName to L"QUARKREC.Cap" with type FixedAtBuild.

Thanks,

Mike

> -Original Message-
> From: Yao, Jiewen
> Sent: Friday, September 30, 2016 5:22 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D 
> mailto:michael.d.kin...@intel.com>>; Steele, Kelly
> mailto:kelly.ste...@intel.com>>; Tian, Feng 
> mailto:feng.t...@intel.com>>; Zeng, Star
> mailto:star.z...@intel.com>>; Gao, Liming 
> mailto:liming@intel.com>>; Zhang, Chao B
> mailto:chao.b.zh...@intel.com>>
> Subject: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
> DSC/FDF.
>
> Add DSC/FDF to generate capsule image.
> It is separated from normal DSC/FDF, because the FDF file need use
> the result of final build.
>
> Cc: Michael D Kinney 
> mailto:michael.d.kin...@intel.com>>
> Cc: Kelly Steele mailto:kelly.ste...@intel.com>>
> Cc: Feng Tian mailto:feng.t...@intel.com>>
> Cc: Star Zeng mailto:star.z...@intel.com>>
> Cc: Liming Gao mailto:liming@intel.com>>
> Cc: Chao Zhang mailto:chao.b.zh...@intel.com>>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao mailto:jiewen@intel.com>>
> ---
>  QuarkPlatformPkg/QuarkCapsule.dsc | 44 +++
>  QuarkPlatformPkg/QuarkCapsule.fdf | 82 
>  2 files changed, 126 insertions(+)
>
> diff --git a/QuarkPlatformPkg/QuarkCapsule.dsc 
> b/QuarkPlatformPkg/QuarkCapsule.dsc
> new file mode 100644
> index 000..3785cbd
> --- /dev/null
> +++ b/QuarkPlatformPkg/QuarkCapsule.dsc
> @@ -0,0 +1,44 @@
> +## @file
> +# Clanton Peak CRB platform with 32-bit DXE for 4MB/8MB flash devices.
> +#
> +# This package provides Clanton Peak CRB platform specific capsule.
> +# Copyright (c) 2016 Intel Corporation.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD 
> License
> +# which accompanies this distribution.  The full text of the license may be 
> found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +#
> +##
> +
> +[Defines]
> +  PLATFORM_NAME  = Quark
> +  PLATFORM_GUID  = 3B9F8782-0799-450C-ACB3-2D8F4504810F
> +  PLATFORM_VERSION   = 0.1
> +  FLASH_DEFINITION   = QuarkPlatformPkg/QuarkCapsule.fdf
> +  OUTPUT_DIRECTORY   = Build/Quark
> +  SUPPORTED_ARCHITECTURES= IA32
> +  BUILD_TARGETS  = DEBUG|RELEASE
> +  SKUID_IDENTIFIER   = DEFAULT
> +
> +
> ###
> +#
> +# Components Section - list of the modules and components that will be 
> processed by
> 

Re: [edk2] [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation DSC/FDF.

2016-10-12 Thread Gao, Liming
Jiewen:
  The latest BaseTools Win32 Binary has supported it. Please try.

From: Yao, Jiewen
Sent: Thursday, October 13, 2016 8:39 AM
To: Kinney, Michael D ; edk2-devel@lists.01.org
Cc: Steele, Kelly ; Tian, Feng ; 
Zeng, Star ; Gao, Liming ; Zhang, 
Chao B 
Subject: RE: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
DSC/FDF.

Yes. I will do that once BaseTool binary is updated.

From: Kinney, Michael D
Sent: Thursday, October 13, 2016 5:01 AM
To: Yao, Jiewen mailto:jiewen@intel.com>>; 
edk2-devel@lists.01.org; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Cc: Steele, Kelly mailto:kelly.ste...@intel.com>>; 
Tian, Feng mailto:feng.t...@intel.com>>; Zeng, Star 
mailto:star.z...@intel.com>>; Gao, Liming 
mailto:liming@intel.com>>; Zhang, Chao B 
mailto:chao.b.zh...@intel.com>>
Subject: RE: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
DSC/FDF.

Jiewen,

Please remove the QuarkCapsule.fdf file and merge those contents into Quark.fdf.

In Quark.fdf, put the FMP and Capsules sections for recovery next to each other
surrounded by !if $(RECOVERY_ENABLE).  With the update to GenFds in BaseTools,
the order of the sections is more flexible, so you can now put the related
sections next to each other in the FDF.

In Quark.fdf, put the FMP and Capsules sections for firmware update next to each
Other surrounded by !if $(CAPSULE_ENABLE).  With the update to GenFds in 
BaseTools,
the order of the sections is more flexible, so you can now put the related
sections next to each other in the FDF.

In Quark.dsc, set PcdRecoveryFileName to L"QUARKREC.Cap" with type FixedAtBuild.

Thanks,

Mike

> -Original Message-
> From: Yao, Jiewen
> Sent: Friday, September 30, 2016 5:22 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D 
> mailto:michael.d.kin...@intel.com>>; Steele, Kelly
> mailto:kelly.ste...@intel.com>>; Tian, Feng 
> mailto:feng.t...@intel.com>>; Zeng, Star
> mailto:star.z...@intel.com>>; Gao, Liming 
> mailto:liming@intel.com>>; Zhang, Chao B
> mailto:chao.b.zh...@intel.com>>
> Subject: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
> DSC/FDF.
>
> Add DSC/FDF to generate capsule image.
> It is separated from normal DSC/FDF, because the FDF file need use
> the result of final build.
>
> Cc: Michael D Kinney 
> mailto:michael.d.kin...@intel.com>>
> Cc: Kelly Steele mailto:kelly.ste...@intel.com>>
> Cc: Feng Tian mailto:feng.t...@intel.com>>
> Cc: Star Zeng mailto:star.z...@intel.com>>
> Cc: Liming Gao mailto:liming@intel.com>>
> Cc: Chao Zhang mailto:chao.b.zh...@intel.com>>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao mailto:jiewen@intel.com>>
> ---
>  QuarkPlatformPkg/QuarkCapsule.dsc | 44 +++
>  QuarkPlatformPkg/QuarkCapsule.fdf | 82 
>  2 files changed, 126 insertions(+)
>
> diff --git a/QuarkPlatformPkg/QuarkCapsule.dsc 
> b/QuarkPlatformPkg/QuarkCapsule.dsc
> new file mode 100644
> index 000..3785cbd
> --- /dev/null
> +++ b/QuarkPlatformPkg/QuarkCapsule.dsc
> @@ -0,0 +1,44 @@
> +## @file
> +# Clanton Peak CRB platform with 32-bit DXE for 4MB/8MB flash devices.
> +#
> +# This package provides Clanton Peak CRB platform specific capsule.
> +# Copyright (c) 2016 Intel Corporation.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD 
> License
> +# which accompanies this distribution.  The full text of the license may be 
> found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +#
> +##
> +
> +[Defines]
> +  PLATFORM_NAME  = Quark
> +  PLATFORM_GUID  = 3B9F8782-0799-450C-ACB3-2D8F4504810F
> +  PLATFORM_VERSION   = 0.1
> +  FLASH_DEFINITION   = QuarkPlatformPkg/QuarkCapsule.fdf
> +  OUTPUT_DIRECTORY   = Build/Quark
> +  SUPPORTED_ARCHITECTURES= IA32
> +  BUILD_TARGETS  = DEBUG|RELEASE
> +  SKUID_IDENTIFIER   = DEFAULT
> +
> +
> ###
> +#
> +# Components Section - list of the modules and components that will be 
> processed by
> compilation
> +#  tools and the EDK II tools to generate 
> PE32/PE32+/Coff image
> files.
> +#
> +# Note: The EDK II DSC file is not used to specify how compiled binary 
> images get
> placed
> +#   into firmware volume images. This section is just a list of modules 
> to
> compile from
> +#   source into UEFI-compliant binaries.
> +#   It is the FDF file that contains information on combining binary 
> files into
> firmware
> +#   volume images, whose concept is beyond UEFI and i

Re: [edk2] [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation DSC/FDF.

2016-10-12 Thread Yao, Jiewen
Yes. I will do that once BaseTool binary is updated.

From: Kinney, Michael D
Sent: Thursday, October 13, 2016 5:01 AM
To: Yao, Jiewen ; edk2-devel@lists.01.org; Kinney, 
Michael D 
Cc: Steele, Kelly ; Tian, Feng ; 
Zeng, Star ; Gao, Liming ; Zhang, 
Chao B 
Subject: RE: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
DSC/FDF.

Jiewen,

Please remove the QuarkCapsule.fdf file and merge those contents into Quark.fdf.

In Quark.fdf, put the FMP and Capsules sections for recovery next to each other
surrounded by !if $(RECOVERY_ENABLE).  With the update to GenFds in BaseTools,
the order of the sections is more flexible, so you can now put the related
sections next to each other in the FDF.

In Quark.fdf, put the FMP and Capsules sections for firmware update next to each
Other surrounded by !if $(CAPSULE_ENABLE).  With the update to GenFds in 
BaseTools,
the order of the sections is more flexible, so you can now put the related
sections next to each other in the FDF.

In Quark.dsc, set PcdRecoveryFileName to L"QUARKREC.Cap" with type FixedAtBuild.

Thanks,

Mike

> -Original Message-
> From: Yao, Jiewen
> Sent: Friday, September 30, 2016 5:22 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D 
> mailto:michael.d.kin...@intel.com>>; Steele, Kelly
> mailto:kelly.ste...@intel.com>>; Tian, Feng 
> mailto:feng.t...@intel.com>>; Zeng, Star
> mailto:star.z...@intel.com>>; Gao, Liming 
> mailto:liming@intel.com>>; Zhang, Chao B
> mailto:chao.b.zh...@intel.com>>
> Subject: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
> DSC/FDF.
>
> Add DSC/FDF to generate capsule image.
> It is separated from normal DSC/FDF, because the FDF file need use
> the result of final build.
>
> Cc: Michael D Kinney 
> mailto:michael.d.kin...@intel.com>>
> Cc: Kelly Steele mailto:kelly.ste...@intel.com>>
> Cc: Feng Tian mailto:feng.t...@intel.com>>
> Cc: Star Zeng mailto:star.z...@intel.com>>
> Cc: Liming Gao mailto:liming@intel.com>>
> Cc: Chao Zhang mailto:chao.b.zh...@intel.com>>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao mailto:jiewen@intel.com>>
> ---
>  QuarkPlatformPkg/QuarkCapsule.dsc | 44 +++
>  QuarkPlatformPkg/QuarkCapsule.fdf | 82 
>  2 files changed, 126 insertions(+)
>
> diff --git a/QuarkPlatformPkg/QuarkCapsule.dsc 
> b/QuarkPlatformPkg/QuarkCapsule.dsc
> new file mode 100644
> index 000..3785cbd
> --- /dev/null
> +++ b/QuarkPlatformPkg/QuarkCapsule.dsc
> @@ -0,0 +1,44 @@
> +## @file
> +# Clanton Peak CRB platform with 32-bit DXE for 4MB/8MB flash devices.
> +#
> +# This package provides Clanton Peak CRB platform specific capsule.
> +# Copyright (c) 2016 Intel Corporation.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD 
> License
> +# which accompanies this distribution.  The full text of the license may be 
> found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +#
> +##
> +
> +[Defines]
> +  PLATFORM_NAME  = Quark
> +  PLATFORM_GUID  = 3B9F8782-0799-450C-ACB3-2D8F4504810F
> +  PLATFORM_VERSION   = 0.1
> +  FLASH_DEFINITION   = QuarkPlatformPkg/QuarkCapsule.fdf
> +  OUTPUT_DIRECTORY   = Build/Quark
> +  SUPPORTED_ARCHITECTURES= IA32
> +  BUILD_TARGETS  = DEBUG|RELEASE
> +  SKUID_IDENTIFIER   = DEFAULT
> +
> +
> ###
> +#
> +# Components Section - list of the modules and components that will be 
> processed by
> compilation
> +#  tools and the EDK II tools to generate 
> PE32/PE32+/Coff image
> files.
> +#
> +# Note: The EDK II DSC file is not used to specify how compiled binary 
> images get
> placed
> +#   into firmware volume images. This section is just a list of modules 
> to
> compile from
> +#   source into UEFI-compliant binaries.
> +#   It is the FDF file that contains information on combining binary 
> files into
> firmware
> +#   volume images, whose concept is beyond UEFI and is described in PI
> specification.
> +#   Binary modules do not need to be listed in this section, as they 
> should be
> +#   specified in the FDF file. For example: Shell binary, FAT binary 
> (Fat.efi),
> +#   Logo (Logo.bmp), and etc.
> +#   There may also be modules listed in this section that are not 
> required in
> the FDF file,
> +#   When a module listed here is excluded from FDF file, then 
> UEFI-compliant
> binary will be
> +#   generated for it, but the binary will not be put into any firmware 
> volume.
> +#
> +###

Re: [edk2] [PATCH] ShellPkg/UefiShellTftpCommandLib: Update TFTP help text

2016-10-12 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 
And pushed.

> -Original Message-
> From: Thomas Palmer [mailto:thomas.pal...@hpe.com]
> Sent: Wednesday, October 12, 2016 1:15 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Carsey, Jaben
> ; joseph.shiffl...@hpe.com; Thomas Palmer
> 
> Subject: [PATCH] ShellPkg/UefiShellTftpCommandLib: Update TFTP help text
> Importance: High
> 
> Clear up some help text for the TFTP shell command
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Thomas Palmer 
> ---
>  .../Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni   | 8
> 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
> b/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
> index a16265c..4f4447d 100644
> ---
> a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
> +++
> b/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
> @@ -1,6 +1,6 @@
>  // /**
>  //
> -// (C) Copyright 2015 Hewlett Packard Enterprise Development LP
> +// (C) Copyright 2015-2016 Hewlett Packard Enterprise Development
> LP
>  // Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. 
>  // This program and the accompanying materials
>  // are licensed and made available under the terms and conditions of the
> BSD License
> @@ -75,11 +75,11 @@
>  " stored locally using the provided file path. If the local file path 
> is\r\n"
>  " not specified, the file is stored in the current directory using the 
> file\r\n"
>  " server's name.\r\n"
> -"  2. Prior to invoke the TFTP command, the network interface intended to
> be\r\n"
> -" used to retrieve the file as to be configured. This configuration may
> be\r\n"
> +"  2. Before using the TFTP command, the network interface intended to
> be\r\n"
> +" used to retrieve the file must be configured. This configuration may
> be\r\n"
>  " done by means of the 'ifconfig' command.\r\n"
>  "  3. If a network interface is defined with the '-i' option then only 
> this\r\n"
> -" interface is used to access to the remote file. Otherwise, all
> network\r\n"
> +" interface will be used to retrieve the remote file. Otherwise, all
> network\r\n"
>  " interfaces are tried in the order they have been discovered during
> the\r\n"
>  " DXE phase.\r\n"
>  ".SH EXAMPLES\r\n"
> --
> 2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 17/45] MdeModulePkg/CapsuleApp: Add CapsuleApp application.

2016-10-12 Thread Carsey, Jaben
I agree.

We should move the 3 protocols from the UEFI Shell Specification from ShellPkg 
to MdePkg.

I think that this is a non-backwards-compatible-change and will require a new 
GUID in ShellPkg.

-Jaben

From: Yao, Jiewen
Sent: Tuesday, October 11, 2016 7:45 AM
To: Ni, Ruiyu ; Carsey, Jaben ; 
Rothman, Michael A ; Kinney, Michael D 
; 'edk2-devel@lists.01.org' 

Cc: Tian, Feng ; Zhang, Chao B ; 
Gao, Liming ; Zeng, Star 
Subject: RE: [PATCH 17/45] MdeModulePkg/CapsuleApp: Add CapsuleApp application.
Importance: High

Yes, I think that is a very good idea.

Shell spec defines EFI_SHELL_PROTOCOL, EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL, 
EFI_SHELL_PARAMETERS_PROTOCOL.
These should be treated as industry stand and we can move these 3 to MdePkg.

SHELL_ENVIRONMENT_2_PROTOCOL and SHELL_INTERFACE_PROTOCOL should be still in 
ShellPkg, since it is not standard.

Thank you
Yao Jiewen


From: Ni, Ruiyu
Sent: Tuesday, October 11, 2016 4:28 PM
To: Carsey, Jaben mailto:jaben.car...@intel.com>>; 
Rothman, Michael A 
mailto:michael.a.roth...@intel.com>>; Yao, Jiewen 
mailto:jiewen@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 
'edk2-devel@lists.01.org' 
mailto:edk2-devel@lists.01.org>>
Cc: Tian, Feng mailto:feng.t...@intel.com>>; Zhang, Chao B 
mailto:chao.b.zh...@intel.com>>; Gao, Liming 
mailto:liming@intel.com>>; Zeng, Star 
mailto:star.z...@intel.com>>
Subject: RE: [PATCH 17/45] MdeModulePkg/CapsuleApp: Add CapsuleApp application.

Jaben,
The reason I propose to move the Shell protocol definitions to MdePkg is that 
all applications that wants to use the ARGV can use the ShellParameter 
protocol, without depending on ShellPkg.

Thanks/Ray

From: Ni, Ruiyu
Sent: Tuesday, October 11, 2016 4:08 PM
To: Carsey, Jaben mailto:jaben.car...@intel.com>>; 
Rothman, Michael A 
mailto:michael.a.roth...@intel.com>>; Yao, Jiewen 
mailto:jiewen@intel.com>>; Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; 
edk2-devel@lists.01.org
Cc: Tian, Feng mailto:feng.t...@intel.com>>; Zhang, Chao B 
mailto:chao.b.zh...@intel.com>>; Gao, Liming 
mailto:liming@intel.com>>; Zeng, Star 
mailto:star.z...@intel.com>>
Subject: RE: [PATCH 17/45] MdeModulePkg/CapsuleApp: Add CapsuleApp application.

Jaben,
How about moving the contents in ShellPkg\Include\Protocol\ to 
MdePkg\Include\Protocol\?
All industry standard protocols are defined in MdePkg, except the Shell related 
protocols.

Thanks/Ray
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation DSC/FDF.

2016-10-12 Thread Kinney, Michael D
Jiewen,

Please remove the QuarkCapsule.fdf file and merge those contents into Quark.fdf.

In Quark.fdf, put the FMP and Capsules sections for recovery next to each other
surrounded by !if $(RECOVERY_ENABLE).  With the update to GenFds in BaseTools,
the order of the sections is more flexible, so you can now put the related
sections next to each other in the FDF.

In Quark.fdf, put the FMP and Capsules sections for firmware update next to 
each 
Other surrounded by !if $(CAPSULE_ENABLE).  With the update to GenFds in 
BaseTools,
the order of the sections is more flexible, so you can now put the related
sections next to each other in the FDF.

In Quark.dsc, set PcdRecoveryFileName to L"QUARKREC.Cap" with type FixedAtBuild.

Thanks,

Mike

> -Original Message-
> From: Yao, Jiewen
> Sent: Friday, September 30, 2016 5:22 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Steele, Kelly
> ; Tian, Feng ; Zeng, Star
> ; Gao, Liming ; Zhang, Chao B
> 
> Subject: [PATCH V2 39/50] QuarkPlatformPkg/dsc/fdf: add capsule generation 
> DSC/FDF.
> 
> Add DSC/FDF to generate capsule image.
> It is separated from normal DSC/FDF, because the FDF file need use
> the result of final build.
> 
> Cc: Michael D Kinney 
> Cc: Kelly Steele 
> Cc: Feng Tian 
> Cc: Star Zeng 
> Cc: Liming Gao 
> Cc: Chao Zhang 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao 
> ---
>  QuarkPlatformPkg/QuarkCapsule.dsc | 44 +++
>  QuarkPlatformPkg/QuarkCapsule.fdf | 82 
>  2 files changed, 126 insertions(+)
> 
> diff --git a/QuarkPlatformPkg/QuarkCapsule.dsc 
> b/QuarkPlatformPkg/QuarkCapsule.dsc
> new file mode 100644
> index 000..3785cbd
> --- /dev/null
> +++ b/QuarkPlatformPkg/QuarkCapsule.dsc
> @@ -0,0 +1,44 @@
> +## @file
> +# Clanton Peak CRB platform with 32-bit DXE for 4MB/8MB flash devices.
> +#
> +# This package provides Clanton Peak CRB platform specific capsule.
> +# Copyright (c) 2016 Intel Corporation.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD 
> License
> +# which accompanies this distribution.  The full text of the license may be 
> found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +#
> +##
> +
> +[Defines]
> +  PLATFORM_NAME  = Quark
> +  PLATFORM_GUID  = 3B9F8782-0799-450C-ACB3-2D8F4504810F
> +  PLATFORM_VERSION   = 0.1
> +  FLASH_DEFINITION   = QuarkPlatformPkg/QuarkCapsule.fdf
> +  OUTPUT_DIRECTORY   = Build/Quark
> +  SUPPORTED_ARCHITECTURES= IA32
> +  BUILD_TARGETS  = DEBUG|RELEASE
> +  SKUID_IDENTIFIER   = DEFAULT
> +
> +
> ###
> +#
> +# Components Section - list of the modules and components that will be 
> processed by
> compilation
> +#  tools and the EDK II tools to generate 
> PE32/PE32+/Coff image
> files.
> +#
> +# Note: The EDK II DSC file is not used to specify how compiled binary 
> images get
> placed
> +#   into firmware volume images. This section is just a list of modules 
> to
> compile from
> +#   source into UEFI-compliant binaries.
> +#   It is the FDF file that contains information on combining binary 
> files into
> firmware
> +#   volume images, whose concept is beyond UEFI and is described in PI
> specification.
> +#   Binary modules do not need to be listed in this section, as they 
> should be
> +#   specified in the FDF file. For example: Shell binary, FAT binary 
> (Fat.efi),
> +#   Logo (Logo.bmp), and etc.
> +#   There may also be modules listed in this section that are not 
> required in
> the FDF file,
> +#   When a module listed here is excluded from FDF file, then 
> UEFI-compliant
> binary will be
> +#   generated for it, but the binary will not be put into any firmware 
> volume.
> +#
> +
> ###
> diff --git a/QuarkPlatformPkg/QuarkCapsule.fdf 
> b/QuarkPlatformPkg/QuarkCapsule.fdf
> new file mode 100644
> index 000..350f4bc
> --- /dev/null
> +++ b/QuarkPlatformPkg/QuarkCapsule.fdf
> @@ -0,0 +1,82 @@
> +## @file
> +# FDF file of Clanton Peak CRB platform with 32-bit DXE
> +#
> +# This package provides QuarkNcSocId platform specific capsule.
> +# Copyright (c) 2016 Intel Corporation.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD 
> License
> +# which accompanies this distribution.  The full text of the license may be 
> found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRI

[edk2] [PATCH] [edk2-staging/HTTPS-TLS][PATCH]: CryptoPkg/TlsLib: Fix FILE_GUID

2016-10-12 Thread Thomas Palmer
TlsLib's FILE_GUID is a duplicate of BaseCryptLib. Use a new unique
guid instead

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Thomas Palmer 
---
 CryptoPkg/Library/TlsLib/TlsLib.inf | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/CryptoPkg/Library/TlsLib/TlsLib.inf 
b/CryptoPkg/Library/TlsLib/TlsLib.inf
index 6194e95..823e159 100644
--- a/CryptoPkg/Library/TlsLib/TlsLib.inf
+++ b/CryptoPkg/Library/TlsLib/TlsLib.inf
@@ -2,6 +2,7 @@
 #  SSL/TLS Wrapper Library Instance based on OpenSSL.
 #
 #  Copyright (c) 2016, Intel Corporation. All rights reserved.
+#  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution.  The full text of the license may be 
found at
@@ -16,7 +17,7 @@
   INF_VERSION= 0x00010005
   BASE_NAME  = TlsLib
   MODULE_UNI_FILE= TlsLib.uni
-  FILE_GUID  = be3bb803-91b6-4da0-bd91-a8b21c18ca5d
+  FILE_GUID  = CC729DC5-4E21-0B36-1A00-3A8E1B86A155
   MODULE_TYPE= DXE_DRIVER
   VERSION_STRING = 1.0
   LIBRARY_CLASS  = TlsLib|DXE_DRIVER DXE_CORE UEFI_APPLICATION 
UEFI_DRIVER
@@ -43,4 +44,4 @@
   OpensslLib
   IntrinsicLib
   PrintLib
-  OpensslTlsLib
\ No newline at end of file
+  OpensslTlsLib
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] Nt32Pkg/WinNtBusDriverDxe: Fix small memory overrun

2016-10-12 Thread Thomas Palmer
When allocating memory for a string, the CHAR16 NUL character needs
two bytes of space. Use StrSize to get accurate size

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Thomas Palmer 
---
 Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c 
b/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c
index 1516ab8..c46ee07 100644
--- a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c
+++ b/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c
@@ -452,8 +452,8 @@ Returns:
 PcdTempStr = (VOID *)LibPcdGetPtr (mPcdEnvironment[Index].Token);
 ASSERT (PcdTempStr != NULL);
 
-TempStrSize = StrLen (PcdTempStr);
-TempStr = AllocateMemory ((TempStrSize * sizeof (CHAR16)) + 1);
+TempStrSize = StrSize (PcdTempStr);
+TempStr = AllocateMemory (TempStrSize);
 StrCpy (TempStr, PcdTempStr);
 
 StartString = TempStr;
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] ShellPkg/UefiShellTftpCommandLib: Update TFTP help text

2016-10-12 Thread Thomas Palmer
Clear up some help text for the TFTP shell command

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Thomas Palmer 
---
 .../Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni   | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni 
b/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
index a16265c..4f4447d 100644
--- a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
+++ b/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
@@ -1,6 +1,6 @@
 // /**
 //
-// (C) Copyright 2015 Hewlett Packard Enterprise Development LP
+// (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
 // Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. 
 // This program and the accompanying materials
 // are licensed and made available under the terms and conditions of the BSD 
License
@@ -75,11 +75,11 @@
 " stored locally using the provided file path. If the local file path 
is\r\n"
 " not specified, the file is stored in the current directory using the 
file\r\n"
 " server's name.\r\n"
-"  2. Prior to invoke the TFTP command, the network interface intended to 
be\r\n"
-" used to retrieve the file as to be configured. This configuration may 
be\r\n"
+"  2. Before using the TFTP command, the network interface intended to be\r\n"
+" used to retrieve the file must be configured. This configuration may 
be\r\n"
 " done by means of the 'ifconfig' command.\r\n"
 "  3. If a network interface is defined with the '-i' option then only 
this\r\n"
-" interface is used to access to the remote file. Otherwise, all 
network\r\n"
+" interface will be used to retrieve the remote file. Otherwise, all 
network\r\n"
 " interfaces are tried in the order they have been discovered during 
the\r\n"
 " DXE phase.\r\n"
 ".SH EXAMPLES\r\n"
-- 
2.7.4

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread Michael Zimmermann
depending on his use case it can be unnecessary to do a low level FS format
though(he said that he just wants to delete all files).

It can also become problematic if you consider that the original filesystem
doesn't have to be FAT.

Thanks
Michael

On Wed, Oct 12, 2016 at 7:46 PM, Richardson, Brian <
brian.richard...@intel.com> wrote:

> There is an effort to move these tools to EDK II. More news as it happens.
>
> Thanks ... br
> ---
> Brian Richardson, Senior Technical Marketing Engineer, Intel Software
> brian.richard...@intel.com -- http://evangelists.intel.com/
> bio/Brian_Richardson_
>
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Blibbet
> Sent: Wednesday, October 12, 2016 1:42 PM
> To: edk2-devel@lists.01.org
> Subject: Re: [edk2] Format a volume in UEFI (or delete all files)
>
>
>
> On 10/12/2016 10:34 AM, GN Keshava wrote:
> > Thanks Laszlo, I'll check it out.
> >
> > I think I need to combine the LS implementation and RM implementation,
> > isn't it? So there is no "format this volume" function or command
> > exists, right?
>
> The commands do exist. But they're not in Tianocore, and have non-BSD
> license, owned by Intel not UEFI Forum.
>
> http://www.intel.com/technology/efi/agree_diskutil.htm
> https://firmwaresecurity.com/2015/09/26/intel-efi-disk-utilities/
>
> But the license is not BSD. It even has a password-protected ZIP, making
> you read the outer zip's readme for the password.
>
> I presume whoever wrote this code at Intel may've read the sources to the
> Microsoft FAT Windows file system code, thus the harsh license.
>
> But now that Microsoft has relicensed the UEFI FAT FS driver, has anyone
> considered relicense the code to these tools too?
>
> Lee
> (former Microsoft file system PM)
>
>
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread Richardson, Brian
There is an effort to move these tools to EDK II. More news as it happens.

Thanks ... br
---
Brian Richardson, Senior Technical Marketing Engineer, Intel Software
brian.richard...@intel.com -- http://evangelists.intel.com/bio/Brian_Richardson_

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Blibbet
Sent: Wednesday, October 12, 2016 1:42 PM
To: edk2-devel@lists.01.org
Subject: Re: [edk2] Format a volume in UEFI (or delete all files)



On 10/12/2016 10:34 AM, GN Keshava wrote:
> Thanks Laszlo, I'll check it out.
>
> I think I need to combine the LS implementation and RM implementation, 
> isn't it? So there is no "format this volume" function or command 
> exists, right?

The commands do exist. But they're not in Tianocore, and have non-BSD license, 
owned by Intel not UEFI Forum.

http://www.intel.com/technology/efi/agree_diskutil.htm
https://firmwaresecurity.com/2015/09/26/intel-efi-disk-utilities/

But the license is not BSD. It even has a password-protected ZIP, making you 
read the outer zip's readme for the password.

I presume whoever wrote this code at Intel may've read the sources to the 
Microsoft FAT Windows file system code, thus the harsh license.

But now that Microsoft has relicensed the UEFI FAT FS driver, has anyone 
considered relicense the code to these tools too?

Lee
(former Microsoft file system PM)


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread Blibbet


On 10/12/2016 10:34 AM, GN Keshava wrote:
> Thanks Laszlo, I'll check it out.
>
> I think I need to combine the LS implementation and RM implementation,
> isn't it? So there is no "format this volume" function or command exists,
> right?

The commands do exist. But they're not in Tianocore, and have non-BSD
license, owned by Intel not UEFI Forum.

http://www.intel.com/technology/efi/agree_diskutil.htm
https://firmwaresecurity.com/2015/09/26/intel-efi-disk-utilities/

But the license is not BSD. It even has a password-protected ZIP, making
you read the outer zip's readme for the password.

I presume whoever wrote this code at Intel may've read the sources to
the Microsoft FAT Windows file system code, thus the harsh license.

But now that Microsoft has relicensed the UEFI FAT FS driver, has anyone
considered relicense the code to these tools too?

Lee
(former Microsoft file system PM)


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread Laszlo Ersek
On 10/12/16 19:34, GN Keshava wrote:
> Thanks Laszlo, I'll check it out.
> 
> I think I need to combine the LS implementation and RM implementation,
> isn't it? So there is no "format this volume" function or command
> exists, right?

I'm unaware of any "format" command. And, I think it's enough if you
look at RM (LS should be unnecessary); RM already contains the recursion.

Laszlo

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread GN Keshava
Thanks Laszlo, I'll check it out.

I think I need to combine the LS implementation and RM implementation,
isn't it? So there is no "format this volume" function or command exists,
right?

Thanks again!
Regards,
Keshava

On Wed 12 Oct, 2016 8:01 pm Laszlo Ersek,  wrote:

> On 10/12/16 12:48, GN Keshava wrote:
> > Hi all,
> >
> > I need to format fs1: (or delete all files and folders in root directory)
> > from my UEFI application.
> >
> > I'm able to use file system APIs such as Open, Write or Delete too. But
> > Delete API needs File (file path) as argument, but what I want is delete
> > all files (irrespective of file name).
> >
> > What could be the best method? Is there any API to directly delete all
> > files? If not, How to go through (Open) all files and delete each?
> >
> > How I can get each file and folder names in a directory programmatically
> ?
>
> Implement recursive directory traversal.
>
> (Minimally) the CP, LS, and TOUCH commands support the "-r" option, for
> recursive operation. I guess you could consult their implementations, if
> you don't want to implement the traversal from scratch.
>
>   ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
>   ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
>   ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
>
> Actually... the RM command supports recursive file & directory removal
> without additional options. The UEFI shell spec 2.2 (Jan 26, 2016) says
> under RM:
>
> This command deletes one or more files or directories. If the
> target is a directory, it will delete the directory, including all
> its subdirectories. [...]
>
> So I guess you could copy & customize the code from
>
>   ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
>
> The CascadeDelete() function looks relevant: "Delete a node and all
> nodes under it (including sub directories)".
>
> Thanks
> Laszlo
>
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] ShellPkg:‘cd \’ command fails to go back to the root directory of a file system

2016-10-12 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 
And pushed.

> -Original Message-
> From: Tapan Shah [mailto:tapands...@hpe.com]
> Sent: Friday, October 07, 2016 2:00 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben ; Tapan Shah
> 
> Subject: [PATCH] ShellPkg:‘cd \’ command fails to go back to the root
> directory of a file system
> Importance: High
> 
> Allows cd command to go back to the root directory when 'cd \' executed in
> system.
> 
> This change prevents last PathRemoveLastItem() call which truncates '\' from
> 'fs0:\'
> in desired root path which is required to set CWD to the root directory.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Tapan Shah 
> ---
>  ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c | 12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
> index 2e51b4c..0967bc7 100644
> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c
> @@ -1,6 +1,7 @@
>  /** @file
>Main file for attrib shell level 2 function.
> 
> +  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
>(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
>Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
>This program and the accompanying materials
> @@ -164,7 +165,16 @@ ShellCommandRunCd (
>StrCpyS (Cwd, StrSize (Directory) / sizeof (CHAR16) + 1, 
> Directory);
>StrCatS (Cwd, StrSize (Directory) / sizeof (CHAR16) + 1, 
> L"\\");
>Drive = GetFullyQualifiedPath (Cwd);
> -  while (PathRemoveLastItem (Drive));
> +  while (PathRemoveLastItem (Drive)) {
> +//
> +// Check if Drive contains 'fsx:\' only or still points to a 
> sub-directory.
> +// Don't remove trailing '\' from Drive if it points to the 
> root
> directory.
> +//
> +Path = StrStr (Drive, L":\\");
> +if ((Path != NULL) && (*(Path + 2) == CHAR_NULL)) {
> +  break;
> +}
> +  }
>FreePool (Cwd);
>  }
>}
> --
> 1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread Blibbet
On 10/12/2016 07:31 AM, Laszlo Ersek wrote:

> On 10/12/16 12:48, GN Keshava wrote:
>> Hi all,
>>
>> I need to format fs1: (or delete all files and folders in root directory)
>> from my UEFI application.
>>
>> I'm able to use file system APIs such as Open, Write or Delete too. But
>> Delete API needs File (file path) as argument, but what I want is delete
>> all files (irrespective of file name).
>>
>> What could be the best method? Is there any API to directly delete all
>> files? If not, How to go through (Open) all files and delete each?
If Microsoft relicensed the FAT FS driver, what about some licensing
help to make the Intel EFI Disk Utility source code BSD, so that could
be be used by others, or even exec'ed?

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch 1/2] BaseTools/GenFds: Support FDF sections in any order

2016-10-12 Thread Kinney, Michael D
Zhu Yonghong,

Thanks for the RB on the first patch in that series.

Your patch: 

  https://lists.01.org/pipermail/edk2-devel/2016-October/002507.html
  [Patch] BaseTools: Extend FMP to support FV statement and FD statement

is a better solution to the OUTPUT_DIRECTORY issue, so I am dropping 

  https://lists.01.org/pipermail/edk2-devel/2016-October/002481.html
  [Patch 2/2] BaseTools/GenFds: Skip parse time OUTPUT_DIRECTORY file verify

Thanks,

Mike

> -Original Message-
> From: Zhu, Yonghong
> Sent: Tuesday, October 11, 2016 9:13 PM
> To: Kinney, Michael D ; edk2-devel@lists.01.org
> Cc: Steele, Kelly ; Gao, Liming 
> ; Zhu,
> Yonghong 
> Subject: RE: [Patch 1/2] BaseTools/GenFds: Support FDF sections in any order
> 
> This patch is fine to me.
> 
> Reviewed-by: Yonghong Zhu 
> 
> Best Regards,
> Zhu Yonghong
> 
> -Original Message-
> From: Kinney, Michael D
> Sent: Saturday, October 08, 2016 5:33 AM
> To: edk2-devel@lists.01.org
> Cc: Steele, Kelly ; Zhu, Yonghong 
> ;
> Gao, Liming 
> Subject: [Patch 1/2] BaseTools/GenFds: Support FDF sections in any order
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=141
> 
> This patch updates EDK II FDF parser in GenFds to allow sections to be placed 
> in any
> order in the FDF file.
> 
> Cc: Kelly Steele 
> Cc: Yonghong Zhu 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney 
> ---
>  BaseTools/Source/Python/GenFds/FdfParser.py | 23 ---
>  1 file changed, 4 insertions(+), 19 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py
> b/BaseTools/Source/Python/GenFds/FdfParser.py
> index 02ae7c9..693128c 100644
> --- a/BaseTools/Source/Python/GenFds/FdfParser.py
> +++ b/BaseTools/Source/Python/GenFds/FdfParser.py
> @@ -1385,25 +1385,10 @@ class FdfParser:
> 
>  try:
>  self.Preprocess()
> -while self.__GetFd():
> -pass
> -
> -while self.__GetFv():
> -pass
> -
> -while self.__GetFmp():
> -pass
> -
> -while self.__GetCapsule():
> -pass
> -
> -while self.__GetVtf():
> -pass
> -
> -while self.__GetRule():
> -pass
> -
> -while self.__GetOptionRom():
> +#
> +# Keep processing sections of the FDF until no new sections or a 
> syntax
> error is found
> +#
> +while self.__GetFd() or self.__GetFv() or self.__GetFmp() or
> self.__GetCapsule() or self.__GetVtf() or self.__GetRule() or 
> self.__GetOptionRom():
>  pass
> 
>  except Warning, X:
> --
> 2.6.3.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread Laszlo Ersek
On 10/12/16 12:48, GN Keshava wrote:
> Hi all,
> 
> I need to format fs1: (or delete all files and folders in root directory)
> from my UEFI application.
> 
> I'm able to use file system APIs such as Open, Write or Delete too. But
> Delete API needs File (file path) as argument, but what I want is delete
> all files (irrespective of file name).
> 
> What could be the best method? Is there any API to directly delete all
> files? If not, How to go through (Open) all files and delete each?
> 
> How I can get each file and folder names in a directory programmatically ?

Implement recursive directory traversal.

(Minimally) the CP, LS, and TOUCH commands support the "-r" option, for
recursive operation. I guess you could consult their implementations, if
you don't want to implement the traversal from scratch.

  ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
  ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
  ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c

Actually... the RM command supports recursive file & directory removal
without additional options. The UEFI shell spec 2.2 (Jan 26, 2016) says
under RM:

This command deletes one or more files or directories. If the
target is a directory, it will delete the directory, including all
its subdirectories. [...]

So I guess you could copy & customize the code from

  ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c

The CascadeDelete() function looks relevant: "Delete a node and all
nodes under it (including sub directories)".

Thanks
Laszlo

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch 0/2] MdePkg DevicePathLib: Check buffer length before use.

2016-10-12 Thread Laszlo Ersek
On 10/12/16 14:39, Eric Dong wrote:
> In IsDevicePathValid API, code should validate the device path
> buffer not exceed the input MaxSize before reference the path
> info. This patched series add this check.
> 
> Eric Dong (2):
>   MdePkg UefiDevicePathLib: Validate buffer length before use buffer.
>   MdePkg UefiDevicePathLibDevicePathProtocol: Validate before use.
> 
>  .../UefiDevicePathLib/DevicePathUtilities.c| 25 
> --
>  .../UefiDevicePathLib.c| 24 +++--
>  2 files changed, 35 insertions(+), 14 deletions(-)
> 

Just a syntactic remark: you don't need the backslash (\) after the
trailing logical-and (&&) operators.

Thanks
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] ArmPlatformPkg: Allocate VRAM as RuntimeServicesData

2016-10-12 Thread Ryan Harkin
On 12 October 2016 at 12:39, Evan Lloyd  wrote:
> Hi Ryan.
> No, this is dead.
> Ard's rebuttal was spot on, and unarguable.   The problem needs fixing, but 
> not in UEFI.
> Please disregard this patch.
>

Thanks, yes, it's ignored.


> Regards,
> Evan
>
>
>>-Original Message-
>>From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>>Sent: 11 October 2016 20:17
>>To: ryan.har...@linaro.org
>>Cc: Evan Lloyd; edk2-devel@lists.01.org; Leif Lindholm
>>Subject: Re: [edk2] ArmPlatformPkg: Allocate VRAM as
>>RuntimeServicesData
>>
>>On 11 October 2016 at 18:44, Ryan Harkin  wrote:
>>> Hi Evan,
>>>
>>> This was sent to the list with no subject line and I wasn't on CC, so
>>> I didn't see it.
>>>
>>> Are you still using this patch and want it in, i.e. does it need
>>> review and test?
>>>
>>
>>I'm sure it works, but I don't think we should take it.
>>RuntimeServicesData can never be released to the OS, so taking an 8MB
>>chunk just in case the OS may decide to drive the framebuffer using
>>the firmware's protocol rather than via a native driver is not
>>something we should have in reference code.
>>
>>The GOP protocol is arguably a hack anyway, since the entire protocol
>>database and driver tree are torn down after ExitBootServices(), while
>>the GOP leaves a live memory range in place that happens to keep
>>operating as a framebuffer. If the OS wants to use this protocol
>>during normal operation, it should take care to reserve this memory
>>region itself.
>>
>>I am aware that not all OSes may behave correctly in this regard. This
>>is mainly due to the fact that GOP is usually implemented by a PCI
>>device, which exposes the framebuffer via a PCI BAR rather than via a
>>system memory range.
>>
>>
>>
>>> On 4 March 2016 at 15:57,   wrote:
 Code at: https://github.com/EvanLloyd/tianocore/commit/
 From: Sami Mujawar 
 Date: Thu, 25 Feb 2016 15:07:40 +
 Subject: [PATCH] ArmPlatformPkg: Allocate VRAM as
>>RuntimeServicesData

 The UEFI specification allows the operating system (OS) to use the
 Graphics Output Protocol (GOP) in the following scenarios:
  a. as part of the startup process and
  b. prior to loading of a high performance OS graphics driver

 If the VRAM is allocated as BootServicesData, then it is unmapped on
 exit boot services. This prevents GOP usage by the OS post exit boot
 services (the second scenario); as it results in a crash when the VRAM
 is accessed.

 This patch fixes the issue by allocating VRAM as RuntimeServicesData.

 Code at:
>>https://github.com/EvanLloyd/tianocore/commit/18fab16a63c59c84c71cd81
>>089a55a4081ebe253

 Contributed-under: TianoCore Contribution Agreement 1.0
 Signed-off-by: Alexei Fedorov 
 Signed-off-by: Girish Pathak 
 Signed-off-by: Sami Mujawar 
 Signed-off-by: Evan Lloyd 
 ---

>>ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
>>mVExpress.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git
>>a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>>ArmVExpress.c
>>b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>>ArmVExpress.c
 index a578467..4ab8862 100644
 ---
>>a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>>ArmVExpress.c
 +++
>>b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>>ArmVExpress.c
 @@ -133,7 +133,7 @@ LcdPlatformGetVram (
} else {
  AllocationType = AllocateAddress;
}
 -  Status = gBS->AllocatePages (AllocationType, EfiBootServicesData,
>>EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
 +  Status = gBS->AllocatePages (AllocationType, EfiRuntimeServicesData,
>>EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
if (EFI_ERROR(Status)) {
  return Status;
}
 --
 2.7.0

 ___
 edk2-devel mailing list
 edk2-devel@lists.01.org
 https://lists.01.org/mailman/listinfo/edk2-devel
>>> ___
>>> edk2-devel mailing list
>>> edk2-devel@lists.01.org
>>> https://lists.01.org/mailman/listinfo/edk2-devel
>
> IMPORTANT NOTICE: The contents of this email and any attachments are 
> confidential and may also be privileged. If you are not the intended 
> recipient, please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy the 
> information in any medium. Thank you.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] MdePkg UefiDevicePathLibDevicePathProtocol: Validate before use.

2016-10-12 Thread Eric Dong
In IsDevicePathValid API, code should validate the device path
buffer not exceed the input MaxSize before reference the path
info.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
Cc: Ruiyu Ni 
---
 .../UefiDevicePathLib.c| 24 +++---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git 
a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c 
b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
index 5cc4b35..ae1000e 100644
--- a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
+++ b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
@@ -2,7 +2,7 @@
   Library instance that implement UEFI Device Path Library class based on 
protocol
   gEfiDevicePathUtilitiesProtocolGuid.
 
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -103,25 +103,35 @@ IsDevicePathValid (
 
   ASSERT (DevicePath != NULL);
 
-  for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = 
NextDevicePathNode (DevicePath)) {
+  if (MaxSize == 0){
+MaxSize = MAX_UINTN;
+  }
+
+  Size = 0;
+  Count = 0;
+
+  while (MaxSize >= sizeof (EFI_DEVICE_PATH_PROTOCOL) && \
+(MaxSize - sizeof (EFI_DEVICE_PATH_PROTOCOL) >= Size) && \
+!IsDevicePathEnd (DevicePath)) {
 NodeLength = DevicePathNodeLength (DevicePath);
 if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
   return FALSE;
 }
 
-if (MaxSize > 0) {
-  Size += NodeLength;
-  if (Size + END_DEVICE_PATH_LENGTH > MaxSize) {
-return FALSE;
-  }
+if (NodeLength > MAX_UINTN - Size) {
+  return FALSE;
 }
 
+Size += NodeLength;
+
 if (PcdGet32 (PcdMaximumDevicePathNodeCount) > 0) {
   Count++;
   if (Count >= PcdGet32 (PcdMaximumDevicePathNodeCount)) {
 return FALSE;
   }
 }
+
+DevicePath = NextDevicePathNode (DevicePath);
   }
 
   //
-- 
2.6.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 0/2] MdePkg DevicePathLib: Check buffer length before use.

2016-10-12 Thread Eric Dong
In IsDevicePathValid API, code should validate the device path
buffer not exceed the input MaxSize before reference the path
info. This patched series add this check.

Eric Dong (2):
  MdePkg UefiDevicePathLib: Validate buffer length before use buffer.
  MdePkg UefiDevicePathLibDevicePathProtocol: Validate before use.

 .../UefiDevicePathLib/DevicePathUtilities.c| 25 --
 .../UefiDevicePathLib.c| 24 +++--
 2 files changed, 35 insertions(+), 14 deletions(-)

-- 
2.6.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 1/2] MdePkg UefiDevicePathLib: Validate buffer length before use buffer.

2016-10-12 Thread Eric Dong
In IsDevicePathValid API, code should validate the device path
buffer not exceed the input MaxSize before reference the path
info.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong 
Cc: Ruiyu Ni 
---
 .../UefiDevicePathLib/DevicePathUtilities.c| 25 --
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
index 7f21a60..48743c5 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
@@ -8,7 +8,7 @@
   environment varibles. Multi-instance device paths should never be placed
   on a Handle.
 
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
   This program and the accompanying materials  
   are licensed and made available under the terms and conditions of the BSD 
License 
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -61,25 +61,35 @@ IsDevicePathValid (
 
   ASSERT (DevicePath != NULL);
 
-  for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = 
NextDevicePathNode (DevicePath)) {
+  if (MaxSize == 0){
+MaxSize = MAX_UINTN;
+  }
+
+  Size = 0;
+  Count = 0;
+
+  while (MaxSize >= sizeof (EFI_DEVICE_PATH_PROTOCOL) && \
+(MaxSize - sizeof (EFI_DEVICE_PATH_PROTOCOL) >= Size) && \
+!IsDevicePathEnd (DevicePath)) {
 NodeLength = DevicePathNodeLength (DevicePath);
 if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
   return FALSE;
 }
 
-if (MaxSize > 0) {
-  Size += NodeLength;
-  if (Size + END_DEVICE_PATH_LENGTH > MaxSize) {
-return FALSE;
-  }
+if (NodeLength > MAX_UINTN - Size) {
+  return FALSE;
 }
 
+Size += NodeLength;
+
 if (PcdGet32 (PcdMaximumDevicePathNodeCount) > 0) {
   Count++;
   if (Count >= PcdGet32 (PcdMaximumDevicePathNodeCount)) {
 return FALSE;
   }
 }
+
+DevicePath = NextDevicePathNode (DevicePath);
   }
 
   //
@@ -88,6 +98,7 @@ IsDevicePathValid (
   return (BOOLEAN) (DevicePathNodeLength (DevicePath) == 
END_DEVICE_PATH_LENGTH);
 }
 
+
 /**
   Returns the Type field of a device path node.
 
-- 
2.6.4.windows.1

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 52/52] BaseTools/VfrCompile/Pccts: Make assignment operator not returning void

2016-10-12 Thread Hao Wu
The assignment operators for class ANTLRTokenPtr return void in current
code.

This commit makes them return the reference to the object just like
primitive types do.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtr.h | 4 ++--
 BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtrImpl.h | 6 --
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtr.h 
b/BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtr.h
index 75b4c86..df89d8f 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtr.h
+++ b/BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtr.h
@@ -58,8 +58,8 @@ public:
 //  7-Apr-97 133MR1
 //  Fix suggested by Andreas Magnusson
 // (andreas.magnus...@mailbox.swipnet.se)
-void operator = (const ANTLRTokenPtr & lhs);   // MR1
-void operator = (ANTLRAbstractToken *addr);
+ANTLRTokenPtr& operator = (const ANTLRTokenPtr & lhs);  // MR1
+ANTLRTokenPtr& operator = (ANTLRAbstractToken *addr);
 int operator != (const ANTLRTokenPtr &q) const // MR1 
// MR11 unsigned -> int
{ return this->ptr_ != q.ptr_; }
 int operator == (const ANTLRTokenPtr &q) const // MR1 
// MR11 unsigned -> int
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtrImpl.h 
b/BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtrImpl.h
index 9c07cf5..a1efc3b 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtrImpl.h
+++ b/BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtrImpl.h
@@ -71,18 +71,20 @@ ANTLRTokenPtr::~ANTLRTokenPtr()
 //  8-Apr-97   MR1 Make operator -> a const member function
 //   as weall as some other member functions
 //
-void ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs) // MR1
+ANTLRTokenPtr& ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs)// MR1
 {
 lhs.ref(); // protect against "xp = xp"; ie same underlying object
 deref();
 ptr_ = lhs.ptr_;
+return *this;
 }
 
-void ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)
+ANTLRTokenPtr& ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)
 {
 if (addr != NULL) {
addr->ref();
 }
 deref();
 ptr_ = addr;
+return *this;
 }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 50/52] BaseTools/VolInfo: Use hard-coded format string for calls to sprintf()

2016-10-12 Thread Hao Wu
For calls to API sprintf(), use hard-coded format string instead of a
local variable.

This helps to prevent the format string from being changed accidentally,
which may lead to potential buffer overflows.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c 
b/BaseTools/Source/C/VolInfo/VolInfo.c
index 5285acd..7ecfb7f 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -1599,7 +1599,6 @@ Returns:
   CHAR8   *ExtractionTool;
   CHAR8   *ToolInputFile;
   CHAR8   *ToolOutputFile;
-  CHAR8   *SystemCommandFormatString;
   CHAR8   *SystemCommand;
   EFI_GUID*EfiGuid;
   UINT16  DataOffset;
@@ -1659,9 +1658,8 @@ Returns:
   SectionLength - SectionHeaderLen
   );
 
-SystemCommandFormatString = "%s sha1 -out %s %s";
 SystemCommand = malloc (
-  strlen (SystemCommandFormatString) +
+  strlen ("%s sha1 -out %s %s") +
   strlen (OpenSslPath) +
   strlen (ToolInputFileName) +
   strlen (ToolOutputFileName) +
@@ -1673,7 +1671,7 @@ Returns:
 }
 sprintf (
   SystemCommand,
-  SystemCommandFormatString,
+  "%s sha1 -out %s %s",
   OpenSslPath,
   ToolOutputFileName,
   ToolInputFileName
@@ -1891,9 +1889,8 @@ Returns:
 //
 // Construction 'system' command string
 //
-SystemCommandFormatString = "%s -d -o %s %s";
 SystemCommand = malloc (
-  strlen (SystemCommandFormatString) +
+  strlen ("%s -d -o %s %s") +
   strlen (ExtractionTool) +
   strlen (ToolInputFile) +
   strlen (ToolOutputFile) +
@@ -1909,7 +1906,7 @@ Returns:
 }
 sprintf (
   SystemCommand,
-  SystemCommandFormatString,
+  "%s -d -o %s %s",
   ExtractionTool,
   ToolOutputFile,
   ToolInputFile
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 51/52] BaseTools/VfrCompile/Pccts: Add virtual destructor for class DLGInputStream

2016-10-12 Thread Hao Wu
Class DLGInputStream defined in DLexerBase.h has a virtual method but no
virtual destructor.

This commit add an empty virtual destructor to avoid potential
memory/resource leak when an object of a class derived from class
DLGInputStream is deleted through a pointer to the DLGInputStream class.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h 
b/BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h
index 667ecfd..b9ca311 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h
+++ b/BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h
@@ -57,6 +57,7 @@ public:
 class DllExportPCCTS DLGInputStream {
 public:
virtual int nextChar() = 0;
+virtual ~DLGInputStream() {};
 };
 
 /* Predefined char stream: Input from FILE */
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 45/52] BaseTools/TianoCompress: Fix file handles not being closed

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/TianoCompress/TianoCompress.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c 
b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index 44dbccf..f810511 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -1764,6 +1764,8 @@ Returns:
   InputLength = 0;
   InputFileName = NULL;
   OutputFileName = NULL;
+  InputFile = NULL;
+  OutputFile = NULL;
   DstSize=0;
   DebugLevel = 0;
   DebugMode = FALSE;
@@ -1927,9 +1929,6 @@ Returns:
   OutputFile = fopen (LongFilePath (OutputFileName), "wb");
   if (OutputFile == NULL) {
 Error (NULL, 0, 0001, "Error opening output file for writing", 
OutputFileName);
-if (InputFile != NULL) {
-  fclose (InputFile);
-}
 goto ERROR;
   }
 
@@ -1962,6 +1961,8 @@ Returns:
   }
 
   fwrite(OutBuffer,(size_t)DstSize, 1, OutputFile);
+  fclose(OutputFile);
+  fclose(InputFile);
   free(Scratch);
   free(FileBuffer);
   free(OutBuffer);
@@ -1999,6 +2000,8 @@ Returns:
   }
 
   fwrite(OutBuffer, (size_t)(Scratch->mOrigSize), 1, OutputFile);
+  fclose(OutputFile);
+  fclose(InputFile);
   free(Scratch);
   free(FileBuffer);
   free(OutBuffer);
@@ -2021,6 +2024,12 @@ ERROR:
   DebugMsg(UTILITY_NAME, 0, DebugLevel, "Decoding Error\n", NULL);
 }
   }
+  if (OutputFile != NULL) {
+fclose(OutputFile);
+  }
+  if (InputFile != NULL) {
+fclose (InputFile);
+  }
   if (Scratch != NULL) {
 free(Scratch);
   }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 42/52] BaseTools/GenFv: Fix file handles not being closed

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenFv/GenFvInternalLib.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index b653a61..54a9d07 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -1161,6 +1161,7 @@ Returns:
   //
   FileBuffer = malloc (FileSize);
   if (FileBuffer == NULL) {
+fclose (NewFile);
 Error (NULL, 0, 4001, "Resouce", "memory cannot be allocated!");
 return EFI_OUT_OF_RESOURCES;
   }
@@ -3506,6 +3507,7 @@ Returns:
   PeFileSize = _filelength (fileno (PeFile));
   PeFileBuffer = (UINT8 *) malloc (PeFileSize);
   if (PeFileBuffer == NULL) {
+fclose (PeFile);
 Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on 
rebase of %s", FileName);
 return EFI_OUT_OF_RESOURCES;
   }
@@ -3761,6 +3763,7 @@ Returns:
 PeFileSize = _filelength (fileno (PeFile));
 PeFileBuffer = (UINT8 *) malloc (PeFileSize);
 if (PeFileBuffer == NULL) {
+  fclose (PeFile);
   Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on 
rebase of %s", FileName);
   return EFI_OUT_OF_RESOURCES;
 }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 40/52] BaseTools/GenBootSector: Fix file handles not being closed

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenBootSector/GenBootSector.c | 35 
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/BaseTools/Source/C/GenBootSector/GenBootSector.c 
b/BaseTools/Source/C/GenBootSector/GenBootSector.c
index efdfcd2..2ab2d2a 100644
--- a/BaseTools/Source/C/GenBootSector/GenBootSector.c
+++ b/BaseTools/Source/C/GenBootSector/GenBootSector.c
@@ -201,6 +201,7 @@ Return:
 //
 // Only care about the disk.
 //
+CloseHandle(VolumeHandle);
 return FALSE;
   } else{
 DriveInfo->DiskNumber = StorageDeviceNumber.DeviceNumber;
@@ -437,8 +438,8 @@ ProcessBsOrMbr (
   BYTE  DiskPartitionBackup[0x200] = {0};
   DWORD BytesReturn;
   INT   DrvNumOffset;
-  HANDLEInputHandle;
-  HANDLEOutputHandle;
+  HANDLEInputHandle = INVALID_HANDLE_VALUE;
+  HANDLEOutputHandle = INVALID_HANDLE_VALUE;
   ERROR_STATUS  Status;
   DWORD InputDbrOffset;
   DWORD OutputDbrOffset;
@@ -448,7 +449,7 @@ ProcessBsOrMbr (
   //
   Status =  GetFileHandle(InputInfo, ProcessMbr, &InputHandle, 
&InputDbrOffset);
   if (Status != ErrorSuccess) {
-return Status;
+goto Done;
   }
 
   //
@@ -456,14 +457,15 @@ ProcessBsOrMbr (
   //
   Status = GetFileHandle(OutputInfo, ProcessMbr, &OutputHandle, 
&OutputDbrOffset);
   if (Status != ErrorSuccess) {
-return Status;
+goto Done;
   }
 
   //
   // Read boot sector from source disk/file
   // 
   if (!ReadFile (InputHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {
-return ErrorFileReadWrite;
+Status = ErrorFileReadWrite;
+goto Done;
   }
 
   if (InputInfo->Type == PathUsb) {
@@ -473,7 +475,8 @@ ProcessBsOrMbr (
   //
   DrvNumOffset = GetDrvNumOffset (DiskPartition);
   if (DrvNumOffset == -1) {
-return ErrorFatType;
+Status = ErrorFatType;
+goto Done;
   }
   //
   // Some legacy BIOS require 0x80 discarding MBR.
@@ -495,7 +498,8 @@ ProcessBsOrMbr (
   // Use original partition table
   //
   if (!ReadFile (OutputHandle, DiskPartitionBackup, 0x200, &BytesReturn, 
NULL)) {
-return ErrorFileReadWrite;
+Status = ErrorFileReadWrite;
+goto Done;
   }
   memcpy (DiskPartition + 0x1BE, DiskPartitionBackup + 0x1BE, 0x40);
   SetFilePointer (OutputHandle, 0, NULL, FILE_BEGIN);
@@ -507,13 +511,19 @@ ProcessBsOrMbr (
   // Write boot sector to taget disk/file
   // 
   if (!WriteFile (OutputHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {
-return ErrorFileReadWrite;
+Status = ErrorFileReadWrite;
+goto Done;
   }
 
-  CloseHandle (InputHandle);
-  CloseHandle (OutputHandle);
+Done:
+  if (InputHandle != INVALID_HANDLE_VALUE) {
+CloseHandle (InputHandle);
+  }
+  if (OutputHandle != INVALID_HANDLE_VALUE) {
+CloseHandle (OutputHandle);
+  }
 
-  return ErrorSuccess;
+  return Status;
 }
 
 void
@@ -630,7 +640,8 @@ GetPathInfo (
 if (f == NULL) {
   fprintf (stderr, "error E2003: File was not provided!\n");
   return ErrorPath;
-}  
+}
+fclose (f);
   }
   PathInfo->Type = PathFile;
   strcpy(PathInfo->PhysicalPath, PathInfo->Path);
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 37/52] BaseTools/VfrCompile: Fix potential memory leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp 
b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index d06c1bc..ec73529 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -113,6 +113,7 @@ CFormPkg::CFormPkg (
   }
   BufferStart = new CHAR8[BufferSize];
   if (BufferStart == NULL) {
+delete Node;
 return;
   }
   BufferEnd   = BufferStart + BufferSize;
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 48/52] BaseTools/VolInfo: Fix potential buffer overflow in scanf functions

2016-10-12 Thread Hao Wu
String width is not specified for '%s' specifier in the format string for
scanf functions. This can result in buffer overflows.

This commit now specifies the string length for '%s' in format strings
according to the size of receiving buffers.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 31 ++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c 
b/BaseTools/Source/C/VolInfo/VolInfo.c
index 07840bf..5285acd 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -2178,6 +2178,8 @@ Returns:
 {
   FILE  *Fptr;
   CHAR8 Line[MAX_LINE_LEN];
+  CHAR8 *FormatString;
+  INTN  FormatLength;
   GUID_TO_BASENAME  *GPtr;
 
   if ((Fptr = fopen (LongFilePath (FileName), "r")) == NULL) {
@@ -2185,18 +2187,44 @@ Returns:
 return EFI_DEVICE_ERROR;
   }
 
+  //
+  // Generate the format string for fscanf
+  //
+  FormatLength = snprintf (
+   NULL,
+   0,
+   "%%%us %%%us",
+   (unsigned) sizeof (GPtr->Guid) - 1,
+   (unsigned) sizeof (GPtr->BaseName) - 1
+   ) + 1;
+
+  FormatString = (CHAR8 *) malloc (FormatLength);
+  if (FormatString == NULL) {
+fclose (Fptr);
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  snprintf (
+FormatString,
+FormatLength,
+"%%%us %%%us",
+(unsigned) sizeof (GPtr->Guid) - 1,
+(unsigned) sizeof (GPtr->BaseName) - 1
+);
+
   while (fgets (Line, sizeof (Line), Fptr) != NULL) {
 //
 // Allocate space for another guid/basename element
 //
 GPtr = malloc (sizeof (GUID_TO_BASENAME));
 if (GPtr == NULL) {
+  free (FormatString);
   fclose (Fptr);
   return EFI_OUT_OF_RESOURCES;
 }
 
 memset ((char *) GPtr, 0, sizeof (GUID_TO_BASENAME));
-if (sscanf (Line, "%s %s", GPtr->Guid, GPtr->BaseName) == 2) {
+if (sscanf (Line, FormatString, GPtr->Guid, GPtr->BaseName) == 2) {
   GPtr->Next= mGuidBaseNameList;
   mGuidBaseNameList = GPtr;
 } else {
@@ -2207,6 +2235,7 @@ Returns:
 }
   }
 
+  free (FormatString);
   fclose (Fptr);
   return EFI_SUCCESS;
 }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 34/52] BaseTools/GenVtf: Fix potential memory leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenVtf/GenVtf.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c 
b/BaseTools/Source/C/GenVtf/GenVtf.c
index 8e75d04..392e4e0 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.c
+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
@@ -1232,11 +1232,13 @@ Returns:
 Vtf1TotalSize += (UINT32) (FileSize + NumAdjustByte);
 Status = UpdateVtfBuffer (CompStartAddress, Buffer, FileSize, FIRST_VTF);
   } else {
+free (Buffer);
 Error (NULL, 0, 2000,"Invalid Parameter", "There's component in second VTF 
so second BaseAddress and Size must be specified!");
 return EFI_INVALID_PARAMETER;
   }
 
   if (EFI_ERROR (Status)) {
+free (Buffer);
 return EFI_ABORTED;
   }
 
@@ -1248,6 +1250,7 @@ Returns:
 
   CompFitPtr->CompAddress = CompStartAddress | IPF_CACHE_BIT;
   if ((FileSize % 16) != 0) {
+free (Buffer);
 Error (NULL, 0, 2000, "Invalid parameter", "Binary FileSize must be a 
multiple of 16.");
 return EFI_INVALID_PARAMETER;
   }
@@ -1389,6 +1392,7 @@ Returns:
   PalFitPtr->CompAddress  = PalStartAddress | IPF_CACHE_BIT;
   //assert ((FileSize % 16) == 0);
   if ((FileSize % 16) != 0) {
+free (Buffer);
 Error (NULL, 0, 2000, "Invalid parameter", "Binary FileSize must be a 
multiple of 16.");
 return EFI_INVALID_PARAMETER;
   }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 49/52] BaseTools/VfrCompile: Explicitly state format string for DebugMsg()

2016-10-12 Thread Hao Wu
For calls to API DebugMsg(), explicitly state format string as "%s" when
the given variable list is a sting.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/VfrCompiler.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp 
b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
index 0e5c7c6..1524584 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
@@ -134,7 +134,7 @@ CVfrCompiler::OptionInitialization (
   strcat (mOptions.OutputDirectory, "\\");
 }
   }
-  DebugMsg (NULL, 0, 9, (CHAR8 *) "Output Directory", 
mOptions.OutputDirectory);
+  DebugMsg (NULL, 0, 9, (CHAR8 *) "Output Directory", (CHAR8 *) "%s", 
mOptions.OutputDirectory);
 } else if (stricmp(Argv[Index], "-b") == 0 || stricmp(Argv[Index], 
"--create-ifr-package") == 0 || stricmp(Argv[Index], "-ibin") == 0) {
   mOptions.CreateIfrPkgFile = TRUE;
 } else if (stricmp(Argv[Index], "-n") == 0 || stricmp(Argv[Index], 
"--no-pre-processing") == 0 || stricmp(Argv[Index], "-nopp") == 0) {
@@ -156,7 +156,7 @@ CVfrCompiler::OptionInitialization (
 goto Fail;
   }
   gCVfrStringDB.SetStringFileName(Argv[Index]);
-  DebugMsg (NULL, 0, 9, (CHAR8 *) "Input string file path", Argv[Index]);
+  DebugMsg (NULL, 0, 9, (CHAR8 *) "Input string file path", (CHAR8 *) 
"%s", Argv[Index]);
 } else if ((stricmp (Argv[Index], "-g") == 0) || (stricmp (Argv[Index], 
"--guid") == 0)) {
   Index++;
   Status = StringToGuid (Argv[Index], &mOptions.OverrideClassGuid);
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 41/52] BaseTools/GenCrc32: Fix file handles not being closed

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenCrc32/GenCrc32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/GenCrc32/GenCrc32.c 
b/BaseTools/Source/C/GenCrc32/GenCrc32.c
index ad8cf57..89a0e3b 100644
--- a/BaseTools/Source/C/GenCrc32/GenCrc32.c
+++ b/BaseTools/Source/C/GenCrc32/GenCrc32.c
@@ -1,7 +1,7 @@
 /** @file
 Calculate Crc32 value and Verify Crc32 value for input data.
 
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -289,6 +289,7 @@ Returns:
   FileBuffer = (UINT8 *) malloc (FileSize);
   if (FileBuffer == NULL) {
 Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated!");
+fclose (InFile);
 goto Finish;
   }
   
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 35/52] BaseTools/Split: Fix potential memory and resource leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/Split/Split.c | 41 +++-
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/BaseTools/Source/C/Split/Split.c b/BaseTools/Source/C/Split/Split.c
index c6f547c..eb83d4c 100644
--- a/BaseTools/Source/C/Split/Split.c
+++ b/BaseTools/Source/C/Split/Split.c
@@ -223,14 +223,15 @@ Returns:
 --*/
 {
   EFI_STATUSStatus = EFI_SUCCESS;
+  INTN  ReturnStatus = STATUS_SUCCESS;
   FILE  *In;
   CHAR8 *InputFileName = NULL;
   CHAR8 *OutputDir = NULL;
   CHAR8 *OutFileName1 = NULL;
   CHAR8 *OutFileName2 = NULL;
   UINT64SplitValue = (UINT64) -1;
-  FILE  *Out1;
-  FILE  *Out2;
+  FILE  *Out1 = NULL;
+  FILE  *Out2 = NULL;
   CHAR8 *OutName1 = NULL;
   CHAR8 *OutName2 = NULL;
   CHAR8 *CurrentDir = NULL;
@@ -366,7 +367,8 @@ Returns:
 OutName1 = (CHAR8*)malloc(strlen(InputFileName) + 16);
 if (OutName1 == NULL) {
   Warning (NULL, 0, 0, NULL, "Memory Allocation Fail.");
-  return STATUS_ERROR;
+  ReturnStatus = STATUS_ERROR;
+  goto Finish;
 }
 strcpy (OutName1, InputFileName);
 strcat (OutName1, "1");
@@ -377,7 +379,8 @@ Returns:
 OutName2 = (CHAR8*)malloc(strlen(InputFileName) + 16);
 if (OutName2 == NULL) {
   Warning (NULL, 0, 0, NULL, "Memory Allocation Fail.");
-  return STATUS_ERROR;
+  ReturnStatus = STATUS_ERROR;
+  goto Finish;
 }
 strcpy (OutName2, InputFileName);
 strcat (OutName2, "2");
@@ -389,20 +392,23 @@ Returns:
 //OutputDirSpecified = TRUE;
 if (chdir(OutputDir) != 0) {
   Warning (NULL, 0, 0, NULL, "Change dir to OutputDir Fail.");
-  return STATUS_ERROR;
+  ReturnStatus = STATUS_ERROR;
+  goto Finish;
 }
   }
 
   CurrentDir = (CHAR8*)getcwd((CHAR8*)0, 0);
   if (EFI_ERROR(CreateDir(&OutFileName1))) {
   Error (OutFileName1, 0, 5, "Create Dir for File1 Fail.", NULL);
-  return STATUS_ERROR;
+  ReturnStatus = STATUS_ERROR;
+  goto Finish;
   }
   chdir(CurrentDir);
 
   if (EFI_ERROR(CreateDir(&OutFileName2))) {
   Error (OutFileName2, 0, 5, "Create Dir for File2 Fail.", NULL);
-  return STATUS_ERROR;
+  ReturnStatus = STATUS_ERROR;
+  goto Finish;
   }
   chdir(CurrentDir);
   free(CurrentDir);
@@ -411,14 +417,16 @@ Returns:
   if (Out1 == NULL) {
 // ("Unable to open file \"%s\"\n", OutFileName1);
 Error (OutFileName1, 0, 1, "File open failure", NULL);
-return STATUS_ERROR;
+ReturnStatus = STATUS_ERROR;
+goto Finish;
   }
 
   Out2 = fopen (LongFilePath (OutFileName2), "wb");
   if (Out2 == NULL) {
 // ("Unable to open file \"%s\"\n", OutFileName2);
 Error (OutFileName2, 0, 1, "File open failure", NULL);
-return STATUS_ERROR;
+ReturnStatus = STATUS_ERROR;
+goto Finish;
   }
 
   for (Index = 0; Index < SplitValue; Index++) {
@@ -439,15 +447,22 @@ Returns:
 fputc (CharC, Out2);
   }
 
+Finish:
   if (OutName1 != NULL) {
 free(OutName1);
   }
   if (OutName2 != NULL) {
 free(OutName2);
   }
-  fclose (In);
-  fclose (Out1);
-  fclose (Out2);
+  if (In != NULL) {
+fclose (In);
+  }
+  if (Out1 != NULL) {
+fclose (Out1);
+  }
+  if (Out2 != NULL) {
+fclose (Out2);
+  }
 
-  return STATUS_SUCCESS;
+  return ReturnStatus;
 }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 44/52] BaseTools/LzmaCompress: Fix file handles not being closed

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/LzmaCompress/LzmaCompress.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c 
b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
index 1de07a3..ee6e1fe 100644
--- a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
+++ b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c
@@ -5,7 +5,7 @@
 LzmaUtil.c -- Test application for LZMA compression
 2008-11-23 : Igor Pavlov : Public domain
 
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -333,8 +333,10 @@ int main2(int numArgs, const char *args[], char *rs)
   if (InFile_Open(&inStream.file, inputFile) != 0)
 return PrintError(rs, "Can not open input file");
 
-  if (OutFile_Open(&outStream.file, outputFile) != 0)
+  if (OutFile_Open(&outStream.file, outputFile) != 0) {
+File_Close(&inStream.file);
 return PrintError(rs, "Can not open output file");
+  }
 
   File_GetLength(&inStream.file, &fileSize);
 
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 47/52] BaseTools/GenVtf: Fix potential buffer overflow in scanf functions

2016-10-12 Thread Hao Wu
String width is not specified for '%s' specifier in the format string for
scanf functions. This can result in buffer overflows.

This commit now specifies the string length for '%s' in format strings
according to the size of receiving buffers.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenVtf/GenVtf.c | 82 +-
 1 file changed, 80 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c 
b/BaseTools/Source/C/GenVtf/GenVtf.c
index 85c771d..9c485d3 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.c
+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
@@ -1045,6 +1045,7 @@ Arguments:
 Returns:
 
   EFI_INVALID_PARAMETER  - The parameter is invalid
+  EFI_OUT_OF_RESOURCES   - Resource can not be allocated
   EFI_SUCCESS- The function completed successfully
 
 --*/
@@ -1062,6 +1063,8 @@ Returns:
   CHAR8   Buff4[10];
   CHAR8   Buff5[10];
   CHAR8   Token[50];
+  CHAR8   *FormatString;
+  INTNFormatLength;
 
   Fp = fopen (LongFilePath (VtfInfo->CompSymName), "rb");
 
@@ -1070,10 +1073,47 @@ Returns:
 return EFI_INVALID_PARAMETER;
   }
 
+  //
+  // Generate the format string for fscanf
+  //
+  FormatLength = snprintf (
+   NULL,
+   0,
+   "%%%us %%%us %%%us %%%us %%%us %%%us %%%us",
+   (unsigned) sizeof (Buff1) - 1,
+   (unsigned) sizeof (Buff2) - 1,
+   (unsigned) sizeof (OffsetStr) - 1,
+   (unsigned) sizeof (Buff3) - 1,
+   (unsigned) sizeof (Buff4) - 1,
+   (unsigned) sizeof (Buff5) - 1,
+   (unsigned) sizeof (Token) - 1
+   ) + 1;
+
+  FormatString = (CHAR8 *) malloc (FormatLength);
+  if (FormatString == NULL) {
+fclose (Fp);
+
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  snprintf (
+FormatString,
+FormatLength,
+"%%%us %%%us %%%us %%%us %%%us %%%us %%%us",
+(unsigned) sizeof (Buff1) - 1,
+(unsigned) sizeof (Buff2) - 1,
+(unsigned) sizeof (OffsetStr) - 1,
+(unsigned) sizeof (Buff3) - 1,
+(unsigned) sizeof (Buff4) - 1,
+(unsigned) sizeof (Buff5) - 1,
+(unsigned) sizeof (Token) - 1
+);
+
   while (fgets (Buff, sizeof (Buff), Fp) != NULL) {
 fscanf (
   Fp,
-  "%s %s %s %s %s %s %s",
+  FormatString,
   Buff1,
   Buff2,
   OffsetStr,
@@ -1096,6 +1136,10 @@ Returns:
 
   memcpy ((VOID *) RelativeAddress, (VOID *) CompStartAddress, sizeof 
(UINT64));
 
+  if (FormatString != NULL) {
+free (FormatString);
+  }
+
   if (Fp != NULL) {
 fclose (Fp);
   }
@@ -2198,6 +2242,8 @@ Returns:
   CHAR8   Section[MAX_LONG_FILE_PATH];
   CHAR8   Token[MAX_LONG_FILE_PATH];
   CHAR8   BaseToken[MAX_LONG_FILE_PATH];
+  CHAR8   *FormatString;
+  INTNFormatLength;
   UINT64  TokenAddress;
   longStartLocation;
 
@@ -2276,6 +2322,37 @@ Returns:
   }
 
   //
+  // Generate the format string for fscanf
+  //
+  FormatLength = snprintf (
+   NULL,
+   0,
+   "%%%us | %%%us | %%%us | %%%us\n",
+   (unsigned) sizeof (Type) - 1,
+   (unsigned) sizeof (Address) - 1,
+   (unsigned) sizeof (Section) - 1,
+   (unsigned) sizeof (Token) - 1
+   ) + 1;
+
+  FormatString = (CHAR8 *) malloc (FormatLength);
+  if (FormatString == NULL) {
+fclose (SourceFile);
+fclose (DestFile);
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return EFI_ABORTED;
+  }
+
+  snprintf (
+FormatString,
+FormatLength,
+"%%%us | %%%us | %%%us | %%%us\n",
+(unsigned) sizeof (Type) - 1,
+(unsigned) sizeof (Address) - 1,
+(unsigned) sizeof (Section) - 1,
+(unsigned) sizeof (Token) - 1
+);
+
+  //
   // Read in the file
   //
   while (feof (SourceFile) == 0) {
@@ -2283,7 +2360,7 @@ Returns:
 //
 // Read a line
 //
-if (fscanf (SourceFile, "%s | %s | %s | %s\n", Type, Address, Section, 
Token) == 4) {
+if (fscanf (SourceFile, FormatString, Type, Address, Section, Token) == 4) 
{
 
   //
   // Get the token address
@@ -2306,6 +2383,7 @@ Returns:
 }
   }
 
+  free (FormatString);
   fclose (SourceFile);
   fclose (DestFile);
   return EFI_SUCCESS;
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 39/52] BaseTools/EfiRom: Fix file handles not being closed

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/EfiRom/EfiRom.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c 
b/BaseTools/Source/C/EfiRom/EfiRom.c
index e862989..afb53cd 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.c
+++ b/BaseTools/Source/C/EfiRom/EfiRom.c
@@ -176,9 +176,6 @@ Returns:
 
 BailOut:
   if (Status == STATUS_SUCCESS) {
-if (FptrOut != NULL) {
-  fclose (FptrOut);
-}
 //
 // Clean up our file list
 //
@@ -189,6 +186,10 @@ BailOut:
 }
   }
 
+  if (FptrOut != NULL) {
+fclose (FptrOut);
+  }
+
   if (mOptions.Verbose) {
 VerboseMsg("%s tool done with return code is 0x%x.\n", UTILITY_NAME, 
GetUtilityStatus ());
   }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 38/52] BaseTools/VolInfo: Fix potential memory leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c 
b/BaseTools/Source/C/VolInfo/VolInfo.c
index 5da6582..312d332 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -258,6 +258,14 @@ Returns:
   continue;
 }
 if ((stricmp (argv[0], "--hash") == 0)) {
+  if (EnableHash == TRUE) {
+//
+// --hash already given in the option, ignore this one
+//
+argc --;
+argv ++;
+continue;
+  }
   EnableHash = TRUE;
   OpenSslCommand = "openssl";
   OpenSslEnv = getenv("OPENSSL_PATH");
@@ -1784,8 +1792,14 @@ Returns:
 }
 
 ScratchBuffer   = malloc (ScratchSize);
+if (ScratchBuffer == NULL) {
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  return EFI_OUT_OF_RESOURCES;
+}
 UncompressedBuffer  = malloc (UncompressedLength);
-if ((ScratchBuffer == NULL) || (UncompressedBuffer == NULL)) {
+if (UncompressedBuffer == NULL) {
+  free (ScratchBuffer);
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
   return EFI_OUT_OF_RESOURCES;
 }
 Status = DecompressFunction (
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 43/52] BaseTools/GenVtf: Fix file handles not being closed

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenVtf/GenVtf.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c 
b/BaseTools/Source/C/GenVtf/GenVtf.c
index 392e4e0..85c771d 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.c
+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
@@ -1164,6 +1164,7 @@ Returns:
 
   if (VtfInfo->PreferredSize) {
 if (FileSize > VtfInfo->CompSize) {
+  fclose (Fp);
   Error (NULL, 0, 2000, "Invalid parameter", "The component size is more 
than specified size.");
   return EFI_ABORTED;
 }
@@ -1173,6 +1174,7 @@ Returns:
 
   Buffer = malloc ((UINTN) FileSize);
   if (Buffer == NULL) {
+fclose (Fp);
 return EFI_OUT_OF_RESOURCES;
   }
   memset (Buffer, 0, (UINTN) FileSize);
@@ -1342,6 +1344,7 @@ Returns:
 
   FileSize = _filelength (fileno (Fp));
   if (FileSize < 64) {
+fclose (Fp);
 Error (NULL, 0, 2000, "Invalid parameter", "PAL_A bin header is 64 bytes, 
so the Bin size must be larger than 64 bytes!");
 return EFI_INVALID_PARAMETER;
   }
@@ -1350,6 +1353,7 @@ Returns:
 
   if (VtfInfo->PreferredSize) {
 if (FileSize > VtfInfo->CompSize) {
+  fclose (Fp);
   Error (NULL, 0, 2000, "Invalid parameter", "The PAL_A Size is more than 
the specified size.");
   return EFI_ABORTED;
 }
@@ -1359,6 +1363,7 @@ Returns:
 
   Buffer = malloc ((UINTN) FileSize);
   if (Buffer == NULL) {
+fclose (Fp);
 return EFI_OUT_OF_RESOURCES;
   }
   memset (Buffer, 0, (UINTN) FileSize);
@@ -1775,11 +1780,13 @@ Returns:
   FileSize = _filelength (fileno (Fp));
 
   if (FileSize > 16) {
+fclose (Fp);
 return EFI_ABORTED;
   }
 
   Buffer = malloc (FileSize);
   if (Buffer == NULL) {
+fclose (Fp);
 return EFI_OUT_OF_RESOURCES;
   }
 
@@ -2548,6 +2555,12 @@ Returns:
   // Get the input VTF file name
   //
   VtfFileName = argv[Index+1];
+  if (VtfFP != NULL) {
+//
+// VTF file name has been given previously, override with the new value
+//
+fclose (VtfFP);
+  }
   VtfFP = fopen (LongFilePath (VtfFileName), "rb");
   if (VtfFP == NULL) {
 Error (NULL, 0, 0001, "Error opening file", VtfFileName);
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 36/52] BaseTools/TianoCompress: Fix potential memory leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/TianoCompress/TianoCompress.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c 
b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index 93cb6c3..44dbccf 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -1906,7 +1906,7 @@ Returns:
 FileBuffer = (UINT8 *) malloc (InputLength);
 if (FileBuffer == NULL) {
   Error (NULL, 0, 4001, "Resource:", "Memory cannot be allocated!");
-  return 1;
+  goto ERROR;
 }
 
 Status = GetFileContents (
@@ -1917,8 +1917,8 @@ Returns:
   }
 
   if (EFI_ERROR(Status)) {
-free(FileBuffer);
-return 1;
+Error (NULL, 0, 0004, "Error getting contents of file: %s", InputFileName);
+goto ERROR;
   }
 
   if (OutputFileName == NULL) {
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 46/52] BaseTools/VolInfo: Fix file handles not being closed

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c 
b/BaseTools/Source/C/VolInfo/VolInfo.c
index 312d332..07840bf 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -2191,6 +2191,7 @@ Returns:
 //
 GPtr = malloc (sizeof (GUID_TO_BASENAME));
 if (GPtr == NULL) {
+  fclose (Fptr);
   return EFI_OUT_OF_RESOURCES;
 }
 
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 23/52] BaseTools/TianoCompress: Fix potential access over array bounds

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/TianoCompress/TianoCompress.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c 
b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index b994d93..93cb6c3 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -2215,7 +2215,7 @@ Returns:
   for (Char = 0; Char < NumOfChar; Char++) {
 
 Len = BitLen[Char];
-if (Len == 0) {
+if (Len == 0 || Len >= 17) {
   continue;
 }
 
@@ -2346,6 +2346,8 @@ Returns:
   volatile UINT16  Index;
   UINT32  Mask;
 
+  assert (nn <= NPT);
+
   Number = (UINT16) GetBits (Sd, nbit);
 
   if (Number == 0) {
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 22/52] BaseTools/GenFv: Fix potential access over array bounds

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenFv/GenFv.c|  9 +++--
 BaseTools/Source/C/GenFv/GenFvInternalLib.c | 55 +++--
 2 files changed, 59 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/C/GenFv/GenFv.c b/BaseTools/Source/C/GenFv/GenFv.c
index 01ae37a..4de24b9 100644
--- a/BaseTools/Source/C/GenFv/GenFv.c
+++ b/BaseTools/Source/C/GenFv/GenFv.c
@@ -4,7 +4,7 @@
   can be found in the Tiano Firmware Volume Generation Utility 
   Specification, review draft.
 
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -337,7 +337,12 @@ Returns:
 Error (NULL, 0, 1003, "Invalid option value", "Input Ffsfile can't be 
null");
 return STATUS_ERROR;
   }
-  strcpy (mFvDataInfo.FvFiles[Index], argv[1]);
+  if (strlen (argv[1]) > MAX_LONG_FILE_PATH - 1) {
+Error (NULL, 0, 1003, "Invalid option value", "Input Ffsfile name %s 
is too long!", argv[1]);
+return STATUS_ERROR;
+  }
+  strncpy (mFvDataInfo.FvFiles[Index], argv[1], MAX_LONG_FILE_PATH - 1);
+  mFvDataInfo.FvFiles[Index][MAX_LONG_FILE_PATH - 1] = 0;
   DebugMsg (NULL, 0, 9, "FV component file", "the %uth name is %s", 
(unsigned) Index + 1, argv[1]);
   argc -= 2;
   argv += 2;
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index 8c769b4..d7c650e 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -374,7 +374,7 @@ Returns:
 }
   }
 
-  for (Index = 0; Index < MAX_NUMBER_OF_FILES_IN_FV; Index++) {
+  for (Index = 0; Number + Index < MAX_NUMBER_OF_FILES_IN_FV; Index++) {
 //
 // Read the FFS file list
 //
@@ -2418,17 +2418,19 @@ Returns:
   UINT8   *FvImage;
   UINTN   FvImageSize;
   FILE*FvFile;
-  CHAR8   FvMapName [MAX_LONG_FILE_PATH];
+  CHAR8   *FvMapName;
   FILE*FvMapFile;
   EFI_FIRMWARE_VOLUME_EXT_HEADER  *FvExtHeader;
   FILE*FvExtHeaderFile;
   UINTN   FileSize;
-  CHAR8   FvReportName[MAX_LONG_FILE_PATH];
+  CHAR8   *FvReportName;
   FILE*FvReportFile;
 
   FvBufferHeader = NULL;
   FvFile = NULL;
+  FvMapName  = NULL;
   FvMapFile  = NULL;
+  FvReportName   = NULL;
   FvReportFile   = NULL;
 
   if (InfFileImage != NULL) {
@@ -2566,8 +2568,34 @@ Returns:
   // FvMap file to log the function address of all modules in one Fvimage
   //
   if (MapFileName != NULL) {
+if (strlen (MapFileName) > MAX_LONG_FILE_PATH - 1) {
+  Error (NULL, 0, 1003, "Invalid option value", "MapFileName %s is too 
long!", MapFileName);
+  Status = EFI_ABORTED;
+  goto Finish;
+}
+
+FvMapName = malloc (strlen (MapFileName) + 1);
+if (FvMapName == NULL) {
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  Status = EFI_OUT_OF_RESOURCES;
+  goto Finish;
+}
+
 strcpy (FvMapName, MapFileName);
   } else {
+if (strlen (FvFileName) + strlen (".map") > MAX_LONG_FILE_PATH - 1) {
+  Error (NULL, 0, 1003, "Invalid option value", "FvFileName %s is too 
long!", FvFileName);
+  Status = EFI_ABORTED;
+  goto Finish;
+}
+
+FvMapName = malloc (strlen (FvFileName) + strlen (".map") + 1);
+if (FvMapName == NULL) {
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  Status = EFI_OUT_OF_RESOURCES;
+  goto Finish;
+}
+
 strcpy (FvMapName, FvFileName);
 strcat (FvMapName, ".map");
   }
@@ -2576,6 +2604,19 @@ Returns:
   //
   // FvReport file to log the FV information in one Fvimage
   //
+  if (strlen (FvFileName) + strlen (".txt") > MAX_LONG_FILE_PATH - 1) {
+Error (NULL, 0, 1003, "Invalid option value", "FvFileName %s is too 
long!", FvFileName);
+Status = EFI_ABORTED;
+goto Finish;
+  }
+
+  FvReportName = malloc (strlen (FvFileName) + strlen (".txt") + 1);
+  if (FvReportName == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+Status = EFI_OUT_OF_RESOURCES;
+goto Finish;
+  }
+
   strcpy (FvReportName, FvFileName);
   strcat (FvReportName, ".txt");
 
@@ -2852,6 +2893,14 @@ Finish:
   if (FvExtHeader != NULL) {
 free (FvExtHeader);
   }
+
+  if (FvMapName != NULL) {
+free (FvMapName);
+  }
+
+  if (FvReportName != NULL) {
+free (FvRep

[edk2] [PATCH 30/52] BaseTools/EfiRom: Fix potential memory leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/EfiRom/EfiRom.c | 70 +++---
 1 file changed, 51 insertions(+), 19 deletions(-)

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c 
b/BaseTools/Source/C/EfiRom/EfiRom.c
index b567c3b..e862989 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.c
+++ b/BaseTools/Source/C/EfiRom/EfiRom.c
@@ -883,9 +883,11 @@ Returns:
   UINT32ClassCode;
   UINT32CodeRevision;
   EFI_STATUS Status;
+  INTN   ReturnStatus;
   BOOLEANEfiRomFlag;
   UINT64 TempValue;
 
+  ReturnStatus = 0;
   FileFlags = 0;
   EfiRomFlag = FALSE;
 
@@ -940,11 +942,13 @@ Returns:
 Status = AsciiStringToUint64(Argv[1], FALSE, &TempValue);
 if (EFI_ERROR (Status)) {
   Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], 
Argv[1]);
-  return 1;
+  ReturnStatus = 1;
+  goto Done;
 }
 if (TempValue >= 0x1) {
   Error (NULL, 0, 2000, "Invalid option value", "Vendor Id %s out of 
range!", Argv[1]);
-  return 1;
+  ReturnStatus = 1;
+  goto Done;
 }
 Options->VendId   = (UINT16) TempValue;
 Options->VendIdValid  = 1;
@@ -959,11 +963,13 @@ Returns:
 Status = AsciiStringToUint64(Argv[1], FALSE, &TempValue);
 if (EFI_ERROR (Status)) {
   Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], 
Argv[1]);
-  return 1;
+  ReturnStatus = 1;
+  goto Done;
 }
 if (TempValue >= 0x1) {
   Error (NULL, 0, 2000, "Invalid option value", "Device Id %s out of 
range!", Argv[1]);
-  return 1;
+  ReturnStatus = 1;
+  goto Done;
 }
 Options->DevId  = (UINT16) TempValue;
 Options->DevIdValid = 1;
@@ -977,11 +983,13 @@ Returns:
 //
 if (Argv[1] == NULL || Argv[1][0] == '-') {
   Error (NULL, 0, 2000, "Invalid parameter", "Missing output file name 
with %s option!", Argv[0]);
-  return STATUS_ERROR;
+  ReturnStatus = STATUS_ERROR;
+  goto Done;
 }
 if (strlen (Argv[1]) > MAX_PATH - 1) {
   Error (NULL, 0, 2000, "Invalid parameter", "Output file name %s is 
too long!", Argv[1]);
-  return STATUS_ERROR;
+  ReturnStatus = STATUS_ERROR;
+  goto Done;
 }
 strncpy (Options->OutFileName, Argv[1], MAX_PATH - 1);
 Options->OutFileName[MAX_PATH - 1] = 0;
@@ -993,7 +1001,8 @@ Returns:
 // Help option
 //
 Usage ();
-return STATUS_ERROR;
+ReturnStatus = STATUS_ERROR;
+goto Done;
   } else if (stricmp (Argv[0], "-b") == 0) {
 //
 // Specify binary files with -b
@@ -1021,11 +1030,13 @@ Returns:
 Status = AsciiStringToUint64(Argv[1], FALSE, &DebugLevel);
 if (EFI_ERROR (Status)) {
   Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], 
Argv[1]);
-  return 1;
+  ReturnStatus = 1;
+  goto Done;
 }
 if (DebugLevel > 9)  {
   Error (NULL, 0, 2000, "Invalid option value", "Debug Level range is 
0-9, current input level is %d", Argv[1]);
-  return 1;
+  ReturnStatus = 1;
+  goto Done;
 }
 if (DebugLevel>=5 && DebugLevel<=9) {
   Options->Debug = TRUE;
@@ -1055,12 +1066,14 @@ Returns:
 Status = AsciiStringToUint64(Argv[1], FALSE, &TempValue);
 if (EFI_ERROR (Status)) {
   Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], 
Argv[1]);
-  return 1;
+  ReturnStatus = 1;
+  goto Done;
 }
 ClassCode = (UINT32) TempValue;
 if (ClassCode & 0xFF00) {
   Error (NULL, 0, 2000, "Invalid parameter", "Class code %s out of 
range!", Argv[1]);
-  return STATUS_ERROR;
+  ReturnStatus = STATUS_ERROR;
+  goto Done;
 }
 if (FileList != NULL && FileList->ClassCode == 0) {
   FileList->ClassCode = ClassCode;
@@ -1076,12 +1089,14 @@ Returns:
 Status = AsciiStringToUint64(Argv[1], FALSE, &TempValue);
 if (EFI_ERROR (Status)) {
   Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], 
Argv[1]);
-  return 1;
+  ReturnStatus = 1;
+  goto Done;
 }
 CodeRevision = (UINT32) TempValue;
 if (CodeRevision & 0x) {
   Error (NULL, 0, 2000, "Invalid parameter", "Code revision %s out of 
range!", Argv[1]);
-  return STATUS_ERROR;
+  ReturnStatus = STATUS_ERROR;
+  goto Done;
 }
 if (FileList != NULL && FileList->CodeRevision == 0) {
   FileList->CodeRevision = (UINT16) CodeRevision;
@@ -1095,7 +1110,8 @@ Returns:
 mOptions.Pci23 = 1;
   } else {
 Error (NULL

[edk2] [PATCH 25/52] BaseTools/VfrCompile: Avoid freeing memory with mismatched functions

2016-10-12 Thread Hao Wu
Memory allocated by operator new[] should be freed using delete[] to avoid
possible memory leak.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/VfrCompiler.cpp   |  4 ++--
 BaseTools/Source/C/VfrCompile/VfrError.cpp  |  4 ++--
 BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp|  6 +++---
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 24 
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.h   |  4 +++-
 5 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp 
b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
index 42c9a5e..0e5c7c6 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
@@ -628,7 +628,7 @@ CVfrCompiler::PreProcess (
 goto Fail;
   }
 
-  delete PreProcessCmd;
+  delete[] PreProcessCmd;
 
 Out:
   SET_RUN_STATUS (STATUS_PREPROCESSED);
@@ -638,7 +638,7 @@ Fail:
   if (!IS_RUN_STATUS(STATUS_DEAD)) {
 SET_RUN_STATUS (STATUS_FAILED);
   }
-  delete PreProcessCmd;
+  delete[] PreProcessCmd;
 }
 
 extern UINT8 VfrParserStart (IN FILE *, IN INPUT_INFO_TO_SYNTAX *);
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp 
b/BaseTools/Source/C/VfrCompile/VfrError.cpp
index 3c506ec..285e175 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp
@@ -2,7 +2,7 @@
   
   VfrCompiler error handler.
 
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -145,7 +145,7 @@ SVfrFileScopeRecord::~SVfrFileScopeRecord (
   )
 {
   if (mFileName != NULL) {
-delete mFileName;
+delete[] mFileName;
   }
 }
 
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp 
b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index 124b8e8..9c76b29 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -56,13 +56,13 @@ SPendingAssign::~SPendingAssign (
   )
 {
   if (mKey != NULL) {
-delete mKey;
+delete[] mKey;
   }
   mAddr   = NULL;
   mLen= 0;
   mLineNo = 0;
   if (mMsg != NULL) {
-delete mMsg;
+delete[] mMsg;
   }
   mNext   = NULL;
 }
@@ -898,7 +898,7 @@ CFormPkg::DeclarePendingQuestion (
 strcpy (NewStr, SName);
 strcat (NewStr, VarStr + strlen (FName));
 ReturnCode = lCVfrVarDataTypeDB.GetDataFieldInfo (NewStr, 
Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize);
-delete NewStr;
+delete[] NewStr;
   }
 } else {
   ReturnCode = VFR_RETURN_UNSUPPORTED;
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp 
b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 24b0bfa..1afa5a2 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -123,7 +123,7 @@ SConfigInfo::~SConfigInfo (
   VOID
   )
 {
-  BUFFER_SAFE_FREE (mValue);
+  ARRAY_SAFE_FREE (mValue);
 }
 
 SConfigItem::SConfigItem (
@@ -200,9 +200,9 @@ SConfigItem::~SConfigItem (
 {
   SConfigInfo  *Info;
 
-  BUFFER_SAFE_FREE (mName);
-  BUFFER_SAFE_FREE (mGuid);
-  BUFFER_SAFE_FREE (mId);
+  ARRAY_SAFE_FREE (mName);
+  ARRAY_SAFE_FREE (mGuid);
+  ARRAY_SAFE_FREE (mId);
   while (mInfoStrList != NULL) {
 Info = mInfoStrList;
 mInfoStrList = mInfoStrList->mNext;
@@ -1393,7 +1393,7 @@ SVfrVarStorageNode::~SVfrVarStorageNode (
   )
 {
   if (mVarStoreName != NULL) {
-delete mVarStoreName;
+delete[] mVarStoreName;
   }
 
   if (mVarStoreType == EFI_VFR_VARSTORE_NAME) {
@@ -2102,7 +2102,7 @@ SVfrDefaultStoreNode::~SVfrDefaultStoreNode (
   )
 {
   if (mRefName != NULL) {
-delete mRefName;
+delete[] mRefName;
   }
 }
 
@@ -2304,7 +2304,7 @@ SVfrRuleNode::~SVfrRuleNode (
   )
 {
   if (mRuleName != NULL) {
-delete mRuleName;
+delete[] mRuleName;
   }
 }
 
@@ -2523,11 +2523,11 @@ SVfrQuestionNode::~SVfrQuestionNode (
   )
 {
   if (mName != NULL) {
-delete mName;
+delete[] mName;
   }
 
   if (mVarIdStr != NULL) {
-delete mVarIdStr;
+delete[] mVarIdStr;
   }
 }
 
@@ -3387,7 +3387,7 @@ CVfrStringDB::GetVarStoreNameFormStringId (
   // Check the String package.
   //
   if (PkgHeader->Header.Type != EFI_HII_PACKAGE_STRINGS) {
-delete StringPtr;
+delete[] StringPtr;
 return NULL;
   }
 
@@ -3414,7 +3414,7 @@ CVfrStringDB::GetVarStoreNameFormStringId (
   //
   Status = FindStringBlock(Current, StringId, &NameOffset, &BlockType);
   if (Status != EFI_SUCCESS) {
-delete StringPtr;
+delete[] StringPtr;
 return NULL;
   }
 
@

[edk2] [PATCH 32/52] BaseTools/GenPage: Fix potential memory leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenPage/GenPage.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/BaseTools/Source/C/GenPage/GenPage.c 
b/BaseTools/Source/C/GenPage/GenPage.c
index 5bf8bf8..16dc144 100644
--- a/BaseTools/Source/C/GenPage/GenPage.c
+++ b/BaseTools/Source/C/GenPage/GenPage.c
@@ -431,9 +431,11 @@ main (
   //
   result = GenBinPage (BaseMemory, InputFile, OutputFile);
   if (result < 0) {
+free (BaseMemory);
 return STATUS_ERROR;
   }
 
+  free (BaseMemory);
   return 0;
 }
 
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 27/52] BaseTools/VfrCompile: Avoid freeing freed memory in classes

2016-10-12 Thread Hao Wu
For classes that contain dynamically allocated data members, copy
constructor and assignment operator should be implemented or both
operations should be prohibited to avoid freeing freed memory caused by
shallow copy.

This commit declares both copy constructor and assignment operator as
'private' for classes that contain dynamically allocated data members.
This will prevent freeing already freed memory.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h |  3 ++
 BaseTools/Source/C/VfrCompile/VfrError.h   | 10 +++-
 BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 12 +
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.h  | 55 ++
 4 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h 
b/BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h
index db6cc18..667ecfd 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h
+++ b/BaseTools/Source/C/VfrCompile/Pccts/h/DLexerBase.h
@@ -119,6 +119,9 @@ public:
 
 /* user must subclass this */
 class DllExportPCCTS DLGLexerBase : public ANTLRTokenStream {
+private:
+DLGLexerBase(const DLGLexerBase&); // Prevent copy-construction
+DLGLexerBase& operator=(const DLGLexerBase&);  // Prevent assignment
 public:
virtual ANTLRTokenType erraction();
 
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.h 
b/BaseTools/Source/C/VfrCompile/VfrError.h
index 8241ce2..4dbc54c 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.h
+++ b/BaseTools/Source/C/VfrCompile/VfrError.h
@@ -2,7 +2,7 @@
   
   VfrCompiler Error definition
 
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -73,6 +73,10 @@ struct SVfrFileScopeRecord {
 
   SVfrFileScopeRecord (IN CHAR8 *, IN UINT32);
   ~SVfrFileScopeRecord();
+
+private:
+  SVfrFileScopeRecord (IN CONST SVfrFileScopeRecord&); // Prevent 
copy-construction
+  SVfrFileScopeRecord& operator= (IN CONST SVfrFileScopeRecord&);  // Prevent 
assignment
 };
 
 class CVfrErrorHandle {
@@ -95,6 +99,10 @@ public:
   UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN CHAR8 
*TokName = NULL);
   UINT8 HandleWarning (IN EFI_VFR_WARNING_CODE, IN UINT32 LineNum = 0, IN 
CHAR8 *TokName = NULL);
   VOID  PrintMsg (IN UINT32 LineNum = 0, IN CHAR8 *TokName = NULL, IN CONST 
CHAR8 *MsgType = "Error", IN CONST CHAR8 *ErrorMsg = "");
+
+private:
+  CVfrErrorHandle (IN CONST CVfrErrorHandle&); // Prevent 
copy-construction
+  CVfrErrorHandle& operator= (IN CONST CVfrErrorHandle&);  // Prevent 
assignment
 };
 
 #define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != 
(v)) { return r; } } while (0)
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h 
b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 3c7964a..17ab14c 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
@@ -87,6 +87,10 @@ struct SPendingAssign {
   VOID   SetAddrAndLen (IN VOID *, IN UINT32);
   VOID   AssignValue (IN VOID *, IN UINT32);
   CHAR8 * GetKey (VOID);
+
+private:
+  SPendingAssign (IN CONST SPendingAssign&); // Prevent 
copy-construction
+  SPendingAssign& operator= (IN CONST SPendingAssign&);  // Prevent assignment
 };
 
 struct SBufferNode {
@@ -139,6 +143,10 @@ public:
   EFI_VFR_RETURN_CODE BuildPkg (OUT PACKAGE_DATA &);
   EFI_VFR_RETURN_CODE GenCFile (IN CHAR8 *, IN FILE *, IN PACKAGE_DATA 
*PkgData = NULL);
 
+private:
+  CFormPkg (IN CONST CFormPkg&); // Prevent copy-construction
+  CFormPkg& operator= (IN CONST CFormPkg&);  // Prevent assignment
+
 public:
   EFI_VFR_RETURN_CODE AssignPending (IN CHAR8 *, IN VOID *, IN UINT32, IN 
UINT32, IN CONST CHAR8 *Msg = NULL);
   VOIDDoPendingAssign (IN CHAR8 *, IN VOID *, IN UINT32);
@@ -237,6 +245,10 @@ public:
   VOIDIfrCreateDefaultForQuestion (IN  SIfrRecord *, IN  
QuestionDefaultRecord *);
   VOIDIfrParseDefaulInfoInQuestion (IN  SIfrRecord *, OUT 
QuestionDefaultRecord *);
   VOIDIfrAddDefaultToBufferConfig (IN  UINT16, IN  SIfrRecord *,IN  
EFI_IFR_TYPE_VALUE);
+
+private:
+  CIfrRecordInfoDB (IN CONST CIfrRecordInfoDB&); // Prevent 
copy-construction
+  CIfrRecordInfoDB& operator= (IN CONST CIfrRecordInfoDB&);  // Prevent 
assignment
 };
 
 extern CIfrRecordInfoDB gCIfrRecordInfoDB;
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h 
b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
index 2e06e4f..59509c3 100644
--- a/BaseTo

[edk2] [PATCH 28/52] BaseTools/VfrCompile: Remove unused local variables

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp 
b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index 9c76b29..d06c1bc 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -828,7 +828,6 @@ CFormPkg::DeclarePendingQuestion (
   UINT32 ShrinkSize = 0;
   EFI_VFR_RETURN_CODE  ReturnCode;
   EFI_VFR_VARSTORE_TYPE VarStoreType  = EFI_VFR_VARSTORE_INVALID;
-  EFI_VARSTORE_ID   VarStoreId= EFI_VARSTORE_ID_INVALID;
 
   //
   // Declare all questions as Numeric in DisableIf True
@@ -1410,7 +1409,6 @@ CIfrRecordInfoDB::IfrRecordAdjust (
   EFI_QUESTION_IDQuestionId;
   UINT32 StackCount;
   UINT32 QuestionScope;
-  UINT32 OpcodeOffset;
   CHAR8  ErrorMsg[MAX_STRING_LEN] = {0, };
   EFI_VFR_RETURN_CODE  Status;
 
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 29/52] BaseTools/C/Common: Fix potential memory leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/Common/Decompress.c | 34 --
 BaseTools/Source/C/Common/FirmwareVolumeBuffer.c   |  1 +
 BaseTools/Source/C/Common/MemoryFile.c |  3 +-
 .../Source/C/Common/ParseGuidedSectionTools.c  |  6 
 4 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Source/C/Common/Decompress.c 
b/BaseTools/Source/C/Common/Decompress.c
index 5768c86..61c8199 100644
--- a/BaseTools/Source/C/Common/Decompress.c
+++ b/BaseTools/Source/C/Common/Decompress.c
@@ -934,7 +934,9 @@ Extract (
   UINT32ScratchSize;
   EFI_STATUSStatus;
 
-  Status = EFI_SUCCESS;
+  Scratch = NULL;
+  Status  = EFI_SUCCESS;
+
   switch (Algorithm) {
   case 0:
 *Destination = (VOID *)malloc(SrcSize);
@@ -948,30 +950,44 @@ Extract (
 Status = EfiGetInfo(Source, SrcSize, DstSize, &ScratchSize);
 if (Status == EFI_SUCCESS) {
   Scratch = (VOID *)malloc(ScratchSize);
+  if (Scratch == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
   *Destination = (VOID *)malloc(*DstSize);
-  if (Scratch != NULL && *Destination != NULL) {
-Status = EfiDecompress(Source, SrcSize, *Destination, *DstSize, 
Scratch, ScratchSize);
-  } else {
-Status = EFI_OUT_OF_RESOURCES;
+  if (*Destination == NULL) {
+free (Scratch);
+return EFI_OUT_OF_RESOURCES;
   }
+
+  Status = EfiDecompress(Source, SrcSize, *Destination, *DstSize, Scratch, 
ScratchSize);
 }
 break;
   case 2:
 Status = TianoGetInfo(Source, SrcSize, DstSize, &ScratchSize);
 if (Status == EFI_SUCCESS) {
   Scratch = (VOID *)malloc(ScratchSize);
+  if (Scratch == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
   *Destination = (VOID *)malloc(*DstSize);
-  if (Scratch != NULL && *Destination != NULL) {
-Status = TianoDecompress(Source, SrcSize, *Destination, *DstSize, 
Scratch, ScratchSize);
-  } else {
-Status = EFI_OUT_OF_RESOURCES;
+  if (*Destination == NULL) {
+free (Scratch);
+return EFI_OUT_OF_RESOURCES;
   }
+
+  Status = TianoDecompress(Source, SrcSize, *Destination, *DstSize, 
Scratch, ScratchSize);
 }
 break;
   default:
 Status = EFI_INVALID_PARAMETER;
   }
 
+  if (Scratch != NULL) {
+free (Scratch);
+  }
+
   return Status;
 }
 
diff --git a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c 
b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
index a287fe1..d4a6353 100644
--- a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
+++ b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
@@ -186,6 +186,7 @@ Returns:
 
   Status = FvBufClearAllFiles (TempFv);
   if (EFI_ERROR (Status)) {
+CommonLibBinderFree (TempFv);
 return Status;
   }
 
diff --git a/BaseTools/Source/C/Common/MemoryFile.c 
b/BaseTools/Source/C/Common/MemoryFile.c
index 00ea0c6..1d90688 100644
--- a/BaseTools/Source/C/Common/MemoryFile.c
+++ b/BaseTools/Source/C/Common/MemoryFile.c
@@ -1,7 +1,7 @@
 /** @file
 This contains some useful functions for accessing files.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -69,6 +69,7 @@ Returns:
 
   NewMemoryFile = malloc (sizeof (*NewMemoryFile));
   if (NewMemoryFile == NULL) {
+free (InputFileImage);
 return EFI_OUT_OF_RESOURCES;
   }
 
diff --git a/BaseTools/Source/C/Common/ParseGuidedSectionTools.c 
b/BaseTools/Source/C/Common/ParseGuidedSectionTools.c
index fc8f488..115cfa4 100644
--- a/BaseTools/Source/C/Common/ParseGuidedSectionTools.c
+++ b/BaseTools/Source/C/Common/ParseGuidedSectionTools.c
@@ -125,10 +125,12 @@ Returns:
 
 Status = StripInfDscStringInPlace (NextLine);
 if (EFI_ERROR (Status)) {
+  free (NextLine);
   break;
 }
 
 if (NextLine[0] == '\0') {
+  free (NextLine);
   continue;
 }
 
@@ -153,8 +155,12 @@ Returns:
   LastGuidTool = NewGuidTool;
 }
   }
+}
+
+if (Tool != NULL) {
   FreeStringList (Tool);
 }
+free (NextLine);
   }
 
   return FirstGuidTool;
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 26/52] BaseTools/VfrCompile: Add assignment operator definition for some classes

2016-10-12 Thread Hao Wu
For class that defines the copy constructor, it is better to add the
assignment operator definition as well.

This commit adds the definition for assignment operator for the classes
with the copy constructor defined.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/VfrFormPkg.h  |  1 +
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 16 
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.h   |  1 +
 3 files changed, 18 insertions(+)

diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h 
b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 051df28..3c7964a 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
@@ -307,6 +307,7 @@ private:
 public:
   CIfrOpHeader (IN UINT8 OpCode, IN VOID *StartAddr, IN UINT8 Length = 0);
   CIfrOpHeader (IN CIfrOpHeader &);
+  CIfrOpHeader& operator=(IN CONST CIfrOpHeader &);
 
   VOID IncLength (UINT8 Size) {
 if ((mHeader->Length + Size) > mHeader->Length) {
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp 
b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 1afa5a2..3ca57ed 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -2390,6 +2390,22 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO (
   mVarTotalSize= Info.mVarTotalSize;
 }
 
+EFI_VARSTORE_INFO&
+EFI_VARSTORE_INFO::operator= (
+  IN CONST EFI_VARSTORE_INFO &Info
+  )
+{
+  if (this != &Info) {
+mVarStoreId  = Info.mVarStoreId;
+mInfo.mVarName   = Info.mInfo.mVarName;
+mInfo.mVarOffset = Info.mInfo.mVarOffset;
+mVarType = Info.mVarType;
+mVarTotalSize= Info.mVarTotalSize;
+  }
+
+  return *this;
+}
+
 BOOLEAN
 EFI_VARSTORE_INFO::operator == (
   IN EFI_VARSTORE_INFO  *Info
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h 
b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
index 35d17a0..2e06e4f 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
@@ -264,6 +264,7 @@ struct EFI_VARSTORE_INFO {
 
   EFI_VARSTORE_INFO (VOID);
   EFI_VARSTORE_INFO (IN EFI_VARSTORE_INFO &);
+  EFI_VARSTORE_INFO& operator=(IN CONST EFI_VARSTORE_INFO &);
   BOOLEAN operator == (IN EFI_VARSTORE_INFO *);
 };
 
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 33/52] BaseTools/GenSec: Fix potential memory leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenSec/GenSec.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/GenSec/GenSec.c 
b/BaseTools/Source/C/GenSec/GenSec.c
index 583ff1d..2249dd6 100644
--- a/BaseTools/Source/C/GenSec/GenSec.c
+++ b/BaseTools/Source/C/GenSec/GenSec.c
@@ -902,6 +902,7 @@ Returns:
   }
 
   if (InputLength == 0) {
+free (FileBuffer);
 Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s 
can't be zero", InputFileName);
 return EFI_NOT_FOUND;
   }
@@ -1215,7 +1216,7 @@ Returns:
 InputFileAlign = (UINT32 *) malloc (MAXIMUM_INPUT_FILE_NUM * sizeof 
(UINT32));
 if (InputFileAlign == NULL) {
   Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
-  return 1;
+  goto Finish;
 }
 memset (InputFileAlign, 1, MAXIMUM_INPUT_FILE_NUM * sizeof (UINT32));
   } else if (InputFileAlignNum % MAXIMUM_INPUT_FILE_NUM == 0) {
@@ -1226,7 +1227,7 @@ Returns:
 
 if (InputFileAlign == NULL) {
   Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
-  return 1;
+  goto Finish;
 }
 memset (&(InputFileAlign[InputFileNum]), 1, (MAXIMUM_INPUT_FILE_NUM * 
sizeof (UINT32)));
   }
@@ -1249,7 +1250,7 @@ Returns:
   InputFileName = (CHAR8 **) malloc (MAXIMUM_INPUT_FILE_NUM * sizeof 
(CHAR8 *));
   if (InputFileName == NULL) {
 Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");
-return 1;
+goto Finish;
   }
   memset (InputFileName, 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (CHAR8 *)));
 } else if (InputFileNum % MAXIMUM_INPUT_FILE_NUM == 0) {
@@ -1263,7 +1264,7 @@ Returns:
 
   if (InputFileName == NULL) {
 Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");
-return 1;
+goto Finish;
   }
   memset (&(InputFileName[InputFileNum]), 0, (MAXIMUM_INPUT_FILE_NUM * 
sizeof (CHAR8 *)));
 }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 24/52] BaseTools/VfrCompile: Fix potential access over array bounds

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/Pccts/h/DLexer.h  |   3 +
 BaseTools/Source/C/VfrCompile/VfrCompiler.cpp   | 132 +---
 BaseTools/Source/C/VfrCompile/VfrCompiler.h |   8 +-
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp |   8 ++
 4 files changed, 135 insertions(+), 16 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/Pccts/h/DLexer.h 
b/BaseTools/Source/C/VfrCompile/Pccts/h/DLexer.h
index 37cac24..f15bff1 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/h/DLexer.h
+++ b/BaseTools/Source/C/VfrCompile/Pccts/h/DLexer.h
@@ -30,6 +30,8 @@
  * 1989-2000
  */
 
+#include 
+
 #define ZZINC {if ( track_columns ) (++_endcol);}
 
 #define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}
@@ -114,6 +116,7 @@ more:
state = dfa_base[automaton];
while (ZZNEWSTATE != DfaStates) {
state = newstate;
+assert(state <= sizeof(dfa)/sizeof(dfa[0]));
ZZCOPY;
ZZGETC;
ZZINC;
diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp 
b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
index 59f4bf3..42c9a5e 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
@@ -69,13 +69,13 @@ CVfrCompiler::OptionInitialization (
   SetUtilityName ((CHAR8*) PROGRAM_NAME);
 
   mOptions.VfrFileName[0]= '\0';
-  mOptions.RecordListFile[0] = '\0';
+  mOptions.RecordListFile= NULL;
   mOptions.CreateRecordListFile  = FALSE;
   mOptions.CreateIfrPkgFile  = FALSE;
-  mOptions.PkgOutputFileName[0]  = '\0';
-  mOptions.COutputFileName[0]= '\0';
+  mOptions.PkgOutputFileName = NULL;
+  mOptions.COutputFileName   = NULL;
   mOptions.OutputDirectory[0]= '\0';
-  mOptions.PreprocessorOutputFileName[0] = '\0';
+  mOptions.PreprocessorOutputFileName= NULL;
   mOptions.VfrBaseFileName[0]= '\0';
   mOptions.IncludePaths  = NULL;
   mOptions.SkipCPreprocessor = TRUE;
@@ -119,7 +119,12 @@ CVfrCompiler::OptionInitialization (
 DebugError (NULL, 0, 1001, "Missing option", "-o missing output 
directory name");
 goto Fail;
   }
-  strcpy (mOptions.OutputDirectory, Argv[Index]);
+  if (strlen (Argv[Index]) > MAX_PATH - 1) {
+DebugError (NULL, 0, 1003, "Invalid option value", "Output directory 
name %s is too long", Argv[Index]);
+goto Fail;
+  }
+  strncpy (mOptions.OutputDirectory, Argv[Index], MAX_PATH - 1);
+  mOptions.OutputDirectory[MAX_PATH - 1] = 0;
   
   CHAR8 lastChar = 
mOptions.OutputDirectory[strlen(mOptions.OutputDirectory) - 1];
   if ((lastChar != '/') && (lastChar != '\\')) {
@@ -176,7 +181,12 @@ CVfrCompiler::OptionInitialization (
 DebugError (NULL, 0, 1001, "Missing option", "VFR file name is not 
specified.");
 goto Fail;
   } else {
-strcpy (mOptions.VfrFileName, Argv[Index]);
+if (strlen (Argv[Index]) > MAX_PATH) {
+  DebugError (NULL, 0, 1003, "Invalid option value", "VFR file name %s is 
too long.", Argv[Index]);
+  goto Fail;
+}
+strncpy (mOptions.VfrFileName, Argv[Index], MAX_PATH - 1);
+mOptions.VfrFileName[MAX_PATH - 1] = 0;
   }
 
   if (SetBaseFileName() != 0) {
@@ -200,14 +210,26 @@ Fail:
   SET_RUN_STATUS (STATUS_DEAD);
 
   mOptions.VfrFileName[0]= '\0';
-  mOptions.RecordListFile[0] = '\0';
   mOptions.CreateRecordListFile  = FALSE;
   mOptions.CreateIfrPkgFile  = FALSE;
-  mOptions.PkgOutputFileName[0]  = '\0';
-  mOptions.COutputFileName[0]= '\0';
   mOptions.OutputDirectory[0]= '\0';
-  mOptions.PreprocessorOutputFileName[0] = '\0';
   mOptions.VfrBaseFileName[0]= '\0';
+  if (mOptions.PkgOutputFileName != NULL) {
+free (mOptions.PkgOutputFileName);
+mOptions.PkgOutputFileName   = NULL;
+  }
+  if (mOptions.COutputFileName != NULL) {
+free (mOptions.COutputFileName);
+mOptions.COutputFileName = NULL;
+  }
+  if (mOptions.PreprocessorOutputFileName != NULL) {
+free (mOptions.PreprocessorOutputFileName);
+mOptions.PreprocessorOutputFileName  = NULL;
+  }
+  if (mOptions.RecordListFile != NULL) {
+free (mOptions.RecordListFile);
+mOptions.RecordListFile  = NULL;
+  }
   if (mOptions.IncludePaths != NULL) {
 delete mOptions.IncludePaths;
 mOptions.IncludePaths= NULL;
@@ -304,8 +326,14 @@ CVfrCompiler::SetBaseFileName (
 return -1;
   }
 
-  strncpy (mOptions.VfrBaseFileName, pFileName, pExt - pFileName);
-  mOptions.VfrBaseFileName[pExt - pFileName] = '\0';
+  *pExt = '\0';
+  if (strlen (pFileName) > MAX_PATH - 1) {
+*pEx

[edk2] [PATCH 31/52] BaseTools/GenFv: Fix potential memory leak

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenFv/GenFvInternalLib.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index d7c650e..b653a61 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -1220,6 +1220,7 @@ Returns:
 if (CompareGuid ((EFI_GUID *) FileBuffer, &mFileGuidArray [Index1]) == 0) {
   Error (NULL, 0, 2000, "Invalid parameter", "the %dth file and %uth file 
have the same file GUID.", (unsigned) Index1 + 1, (unsigned) Index + 1);
   PrintGuid ((EFI_GUID *) FileBuffer);
+  free (FileBuffer);
   return EFI_INVALID_PARAMETER;
 }
   }
@@ -2626,7 +2627,7 @@ Returns:
   //
   Status = CalculateFvSize (&mFvDataInfo);
   if (EFI_ERROR (Status)) {
-return Status;
+goto Finish;
   }
   VerboseMsg ("the generated FV image size is %u bytes", (unsigned) 
mFvDataInfo.Size);
   
@@ -2640,7 +2641,8 @@ Returns:
   //
   FvBufferHeader = malloc (FvImageSize + sizeof (UINT64));
   if (FvBufferHeader == NULL) {
-return EFI_OUT_OF_RESOURCES;
+Status = EFI_OUT_OF_RESOURCES;
+goto Finish;
   }
   FvImage = (UINT8 *) (((UINTN) FvBufferHeader + 7) & ~7);
 
@@ -2732,7 +2734,8 @@ Returns:
   FvMapFile = fopen (LongFilePath (FvMapName), "w");
   if (FvMapFile == NULL) {
 Error (NULL, 0, 0001, "Error opening file", FvMapName);
-return EFI_ABORTED;
+Status = EFI_ABORTED;
+goto Finish;
   }
   
   //
@@ -2741,7 +2744,8 @@ Returns:
   FvReportFile = fopen (LongFilePath (FvReportName), "w");
   if (FvReportFile == NULL) {
 Error (NULL, 0, 0001, "Error opening file", FvReportName);
-return EFI_ABORTED;
+Status = EFI_ABORTED;
+goto Finish;
   }
   //
   // record FV size information into FvMap file.
@@ -4259,6 +4263,7 @@ Returns:
 
   fwrite (CapBuffer, 1, CapSize, fpout);
   fclose (fpout);
+  free (CapBuffer);
   
   VerboseMsg ("The size of the generated capsule image is %u bytes", 
(unsigned) CapSize);
 
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 19/52] BaseTools/GenVtf: Fix parameter format mismatch in scanf functions

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenVtf/GenVtf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c 
b/BaseTools/Source/C/GenVtf/GenVtf.c
index b68d86a..8e75d04 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.c
+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
@@ -123,8 +123,8 @@ Returns:
 sscanf (
   Str,
   "%02x.%02x",
-  &Major,
-  &Minor
+  (INT32 *) &Major,
+  (INT32 *) &Minor
   );
   } else {
 Length = strlen(Str);
@@ -137,8 +137,8 @@ Returns:
 sscanf (
   TemStr,
   "%02x%02x",
-  &Major,
-  &Minor
+  (INT32 *) &Major,
+  (INT32 *) &Minor
   );
   }
 
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 15/52] BaseTools/VolInfo: Fix parameter format mismatch in printf functions

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c 
b/BaseTools/Source/C/VolInfo/VolInfo.c
index 1ea2f49..5da6582 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -1708,7 +1708,7 @@ Returns:
   break;
 
 case EFI_SECTION_USER_INTERFACE:
-  printf ("  String: %ls\n", (CHAR16 *) &((EFI_USER_INTERFACE_SECTION *) 
Ptr)->FileNameString);
+  printf ("  String: %ls\n", (wchar_t *) &((EFI_USER_INTERFACE_SECTION *) 
Ptr)->FileNameString);
   break;
 
 case EFI_SECTION_FIRMWARE_VOLUME_IMAGE:
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 20/52] BaseTools/C/Common: Fix potential access over array bounds

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/Common/CommonLib.c  | 8 ++--
 BaseTools/Source/C/Common/Decompress.c | 7 +--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/Common/CommonLib.c 
b/BaseTools/Source/C/Common/CommonLib.c
index 2d07dfc..2f0aecf 100644
--- a/BaseTools/Source/C/Common/CommonLib.c
+++ b/BaseTools/Source/C/Common/CommonLib.c
@@ -1,7 +1,7 @@
 /** @file
 Common basic Library Functions
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -652,7 +652,11 @@ Returns:
 //
 // Construct the full file path
 //
-strcat (mCommonLibFullPath, FileName);
+if (strlen (mCommonLibFullPath) + strlen (FileName) > MAX_LONG_FILE_PATH - 
1) {
+  Error (NULL, 0, 2000, "Invalid parameter", "FileName %s is too long!", 
FileName);
+  return NULL;
+}
+strncat (mCommonLibFullPath, FileName, MAX_LONG_FILE_PATH - strlen 
(mCommonLibFullPath) - 1);
 
 //
 // Convert directory separator '/' to '\\'
diff --git a/BaseTools/Source/C/Common/Decompress.c 
b/BaseTools/Source/C/Common/Decompress.c
index 48578ea..5768c86 100644
--- a/BaseTools/Source/C/Common/Decompress.c
+++ b/BaseTools/Source/C/Common/Decompress.c
@@ -2,7 +2,7 @@
 Decompressor. Algorithm Ported from OPSD code (Decomp.asm) for Efi and Tiano 
 compress algorithm.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 #include 
 #include 
+#include 
 #include "Decompress.h"
 
 //
@@ -240,7 +241,7 @@ Returns:
   for (Char = 0; Char < NumOfChar; Char++) {
 
 Len = BitLen[Char];
-if (Len == 0) {
+if (Len == 0 || Len >= 17) {
   continue;
 }
 
@@ -373,6 +374,8 @@ Returns:
   UINT16  Index;
   UINT32  Mask;
 
+  assert (nn <= NPT);
+
   Number = (UINT16) GetBits (Sd, nbit);
 
   if (Number == 0) {
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 21/52] BaseTools/EfiRom: Fix potential access over array bounds

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/EfiRom/EfiRom.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c 
b/BaseTools/Source/C/EfiRom/EfiRom.c
index 32aa3dc..b567c3b 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.c
+++ b/BaseTools/Source/C/EfiRom/EfiRom.c
@@ -979,7 +979,12 @@ Returns:
   Error (NULL, 0, 2000, "Invalid parameter", "Missing output file name 
with %s option!", Argv[0]);
   return STATUS_ERROR;
 }
-strcpy (Options->OutFileName, Argv[1]);
+if (strlen (Argv[1]) > MAX_PATH - 1) {
+  Error (NULL, 0, 2000, "Invalid parameter", "Output file name %s is 
too long!", Argv[1]);
+  return STATUS_ERROR;
+}
+strncpy (Options->OutFileName, Argv[1], MAX_PATH - 1);
+Options->OutFileName[MAX_PATH - 1] = 0;
 
 Argv++;
 Argc--;
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 16/52] BaseTools/C/Common: Fix parameter format mismatch in scanf functions

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/Common/ParseInf.c  | 24 
 BaseTools/Source/C/Common/SimpleFileParsing.c | 14 +++---
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/BaseTools/Source/C/Common/ParseInf.c 
b/BaseTools/Source/C/Common/ParseInf.c
index 9e85a88..28ed1ca 100644
--- a/BaseTools/Source/C/Common/ParseInf.c
+++ b/BaseTools/Source/C/Common/ParseInf.c
@@ -1,7 +1,7 @@
 /** @file
 This contains some useful functions for parsing INF files.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -429,17 +429,17 @@ Returns:
   Index = sscanf (
 AsciiGuidBuffer,
 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-&Data1,
-&Data2,
-&Data3,
-&Data4[0],
-&Data4[1],
-&Data4[2],
-&Data4[3],
-&Data4[4],
-&Data4[5],
-&Data4[6],
-&Data4[7]
+(INT32 *) &Data1,
+(INT32 *) &Data2,
+(INT32 *) &Data3,
+(INT32 *) &Data4[0],
+(INT32 *) &Data4[1],
+(INT32 *) &Data4[2],
+(INT32 *) &Data4[3],
+(INT32 *) &Data4[4],
+(INT32 *) &Data4[5],
+(INT32 *) &Data4[6],
+(INT32 *) &Data4[7]
 );
 
   //
diff --git a/BaseTools/Source/C/Common/SimpleFileParsing.c 
b/BaseTools/Source/C/Common/SimpleFileParsing.c
index 877bb6f..a99a0ea 100644
--- a/BaseTools/Source/C/Common/SimpleFileParsing.c
+++ b/BaseTools/Source/C/Common/SimpleFileParsing.c
@@ -1,7 +1,7 @@
 /** @file
 Generic but simple file parsing routines.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -547,7 +547,7 @@ Returns:
   }
 
   mGlobals.SourceFile.FileBufferPtr += 2;
-  sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", &Val);
+  sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", (INT32 *) &Val);
   *Value = (UINT32) Val;
   while (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {
 mGlobals.SourceFile.FileBufferPtr++;
@@ -1305,7 +1305,7 @@ Returns:
   goto Done;
 }
 
-sscanf (TempString, "%x", &Value32);
+sscanf (TempString, "%x", (INT32 *) &Value32);
 Value->Data1 = Value32;
 //
 // Next two UINT16 fields
@@ -1320,7 +1320,7 @@ Returns:
   goto Done;
 }
 
-sscanf (TempString, "%x", &Value32);
+sscanf (TempString, "%x", (INT32 *) &Value32);
 Value->Data2 = (UINT16) Value32;
 
 if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {
@@ -1333,7 +1333,7 @@ Returns:
   goto Done;
 }
 
-sscanf (TempString, "%x", &Value32);
+sscanf (TempString, "%x", (INT32 *) &Value32);
 Value->Data3 = (UINT16) Value32;
 //
 // Parse the "" as two bytes
@@ -1348,7 +1348,7 @@ Returns:
   goto Done;
 }
 
-sscanf (TempString, "%x", &Value32);
+sscanf (TempString, "%x", (INT32 *) &Value32);
 Value->Data4[0] = (UINT8) (Value32 >> 8);
 Value->Data4[1] = (UINT8) Value32;
 if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {
@@ -1393,7 +1393,7 @@ Returns:
   //
   TempString2[0]  = TempString[Index * 2];
   TempString2[1]  = TempString[Index * 2 + 1];
-  sscanf (TempString2, "%x", &Value32);
+  sscanf (TempString2, "%x", (INT32 *) &Value32);
   Value->Data4[Index + 2] = (UINT8) Value32;
 }
 
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 17/52] BaseTools/GenFv: Fix parameter format mismatch in scanf functions

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenFv/GenFvInternalLib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index f7e3ba5..8c769b4 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -908,7 +908,7 @@ Returns:
 FunctionType = 2;
 fgets (Line, MAX_LINE_LEN, PeMapFile);
   } else if (stricmp (KeyWord, "Preferred") ==0) {
-sscanf (Line + strlen (" Preferred load address is"), "%llx", 
&TempLongAddress);
+sscanf (Line + strlen (" Preferred load address is"), "%llx", (long 
long *) &TempLongAddress);
 LinkTimeBaseAddress = (UINT64) TempLongAddress;
   }
   continue;
@@ -917,14 +917,14 @@ Returns:
 // Printf Function Information
 //
 if (FunctionType == 1) {
-  sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, &TempLongAddress, 
FunctionTypeName);
+  sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, (long long *) 
&TempLongAddress, FunctionTypeName);
   FunctionAddress = (UINT64) TempLongAddress;
   if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || 
FunctionTypeName [0] == 'F')) {
 fprintf (FvMapFile, "  0x%010llx", (unsigned long long) 
(ImageBaseAddress + FunctionAddress - LinkTimeBaseAddress));
 fprintf (FvMapFile, "%s\n", FunctionName);
   }
 } else if (FunctionType == 2) {
-  sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, &TempLongAddress, 
FunctionTypeName);
+  sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, (long long *) 
&TempLongAddress, FunctionTypeName);
   FunctionAddress = (UINT64) TempLongAddress;
   if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || 
FunctionTypeName [0] == 'F')) {
 fprintf (FvMapFile, "  0x%010llx", (unsigned long long) 
(ImageBaseAddress + FunctionAddress - LinkTimeBaseAddress));
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 18/52] BaseTools/GenFw: Fix parameter format mismatch in scanf functions

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenFw/GenFw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index c0d1e6a..c74d083 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -3198,7 +3198,7 @@ Returns:
 for (; *cptr && isspace((int)*cptr); cptr++) {
 }
 if (isxdigit ((int)*cptr)) {
-  if (sscanf (cptr, "%X", &ScannedData) != 1) {
+  if (sscanf (cptr, "%X", (INT32 *) &ScannedData) != 1) {
 return STATUS_ERROR;
   }
 }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 05/52] BaseTools/GenFw: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenFw/Elf32Convert.c |  8 
 BaseTools/Source/C/GenFw/Elf64Convert.c | 10 +-
 BaseTools/Source/C/GenFw/ElfConvert.c   |  7 ++-
 BaseTools/Source/C/GenFw/GenFw.c| 18 --
 4 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c 
b/BaseTools/Source/C/GenFw/Elf32Convert.c
index 8fca7fb..f420bc8 100644
--- a/BaseTools/Source/C/GenFw/Elf32Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf32Convert.c
@@ -167,6 +167,10 @@ InitializeElf32 (
   // Create COFF Section offset buffer and zero.
   //
   mCoffSectionsOffset = (UINT32 *)malloc(mEhdr->e_shnum * sizeof (UINT32));
+  if (mCoffSectionsOffset == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return FALSE;
+  }
   memset(mCoffSectionsOffset, 0, mEhdr->e_shnum * sizeof(UINT32));
 
   //
@@ -526,6 +530,10 @@ ScanSections32 (
   // Allocate base Coff file.  Will be expanded later for relocations.
   //
   mCoffFile = (UINT8 *)malloc(mCoffOffset);
+  if (mCoffFile == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  }
+  assert (mCoffFile != NULL);
   memset(mCoffFile, 0, mCoffOffset);
 
   //
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c 
b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 9b409b6..acf0216 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -1,7 +1,7 @@
 /** @file
 Elf64 convert solution
 
-Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
 Portions copyright (c) 2013-2014, ARM Ltd. All rights reserved.
 
 This program and the accompanying materials are licensed and made available
@@ -172,6 +172,10 @@ InitializeElf64 (
   //
   VerboseMsg ("Create COFF Section Offset Buffer");
   mCoffSectionsOffset = (UINT32 *)malloc(mEhdr->e_shnum * sizeof (UINT32));
+  if (mCoffSectionsOffset == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return FALSE;
+  }
   memset(mCoffSectionsOffset, 0, mEhdr->e_shnum * sizeof(UINT32));
 
   //
@@ -518,6 +522,10 @@ ScanSections64 (
   // Allocate base Coff file.  Will be expanded later for relocations.
   //
   mCoffFile = (UINT8 *)malloc(mCoffOffset);
+  if (mCoffFile == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  }
+  assert (mCoffFile != NULL);
   memset(mCoffFile, 0, mCoffOffset);
 
   //
diff --git a/BaseTools/Source/C/GenFw/ElfConvert.c 
b/BaseTools/Source/C/GenFw/ElfConvert.c
index 6211389..17913ff 100644
--- a/BaseTools/Source/C/GenFw/ElfConvert.c
+++ b/BaseTools/Source/C/GenFw/ElfConvert.c
@@ -1,7 +1,7 @@
 /** @file
 Elf convert solution
 
-Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
 
 This program and the accompanying materials are licensed and made available 
 under the terms and conditions of the BSD License which accompanies this 
@@ -24,6 +24,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -98,6 +99,10 @@ CoffAddFixup(
   mCoffFile,
   mCoffOffset + sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT
   );
+if (mCoffFile == NULL) {
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+}
+assert (mCoffFile != NULL);
 memset (
   mCoffFile + mCoffOffset, 0,
   sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index 03bfaa1..c0d1e6a 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -625,6 +625,10 @@ PeCoffConvertImageToXip (
   // Allocate the extra space that we need to grow the image
   //
   XipFile = malloc (XipLength);
+  if (XipFile == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return;
+  }
   memset (XipFile, 0, XipLength);
 
   //
@@ -701,6 +705,10 @@ Returns:
   + 3 * (sizeof (UINT16) + 3 * sizeof (CHAR16)) 
   + sizeof (EFI_IMAGE_RESOURCE_DATA_ENTRY);
   HiiSectionHeader = malloc (HiiSectionHeaderSize);
+  if (HiiSectionHeader == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return NULL;
+  }
   memset (HiiSectionHeader, 0, HiiSectionHeaderSize);
 
   HiiSectionOffset = 0;
@@ -1693,6 +1701,10 @@ Returns:
   // Create the resource section header
   //
   HiiSectionHeader = CreateHiiResouceSectionHeader (&HiiSectionHeaderSize, 
HiiPackageListHeader.PackageLength);
+  if (HiiSectionHeader == NULL) {
+free (HiiPackageListBuffer);
+goto Finish;
+  }
   //
   // 

[edk2] [PATCH 08/52] BaseTools/GenVtf: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenVtf/GenVtf.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c 
b/BaseTools/Source/C/GenVtf/GenVtf.c
index f6765dd..b68d86a 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.c
+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
@@ -1125,6 +1125,7 @@ Returns:
   EFI_ABORTED  - Aborted due to one of the many reasons like:
   (a) Component Size greater than the specified size.
   (b) Error opening files.
+  (c) Fail to get the FIT table address.
 
   EFI_INVALID_PARAMETER Value returned from call to UpdateEntryPoint()
   EFI_OUT_OF_RESOURCES  Memory allocation failure.
@@ -1240,6 +1241,10 @@ Returns:
   }
 
   GetNextAvailableFitPtr (&CompFitPtr);
+  if (CompFitPtr == NULL) {
+free (Buffer);
+return EFI_ABORTED;
+  }
 
   CompFitPtr->CompAddress = CompStartAddress | IPF_CACHE_BIT;
   if ((FileSize % 16) != 0) {
@@ -2652,6 +2657,7 @@ Returns:
 }
 SymFileName = VTF_SYM_FILE;
   } else {
+assert (OutFileName1);
 INTN OutFileNameLen = strlen(OutFileName1);
 INTN NewIndex;
 
@@ -2665,6 +2671,10 @@ Returns:
 } else {
   INTN SymFileNameLen = NewIndex + 1 + strlen(VTF_SYM_FILE);
   SymFileName = malloc(SymFileNameLen + 1);
+  if (SymFileName == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+goto ERROR;
+  }
   memcpy(SymFileName, OutFileName1, NewIndex + 1);
   memcpy(SymFileName + NewIndex + 1, VTF_SYM_FILE, strlen(VTF_SYM_FILE));
   SymFileName[SymFileNameLen] = '\0';
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 10/52] BaseTools/VfrCompile: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp| 16 +++-
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp |  2 +-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp 
b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index 0b7b8b1..aa27ce0 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 **/
 
 #include "stdio.h"
+#include "assert.h"
 #include "VfrFormPkg.h"
 
 /*
@@ -669,6 +670,8 @@ CFormPkg::AdjustDynamicInsertOpcode (
 
   InserPositionNode  = GetBinBufferNodeForAddr(InserPositionAddr);
   InsertOpcodeNode = GetBinBufferNodeForAddr(InsertOpcodeAddr);
+  assert (InserPositionNode != NULL);
+  assert (InsertOpcodeNode  != NULL);
 
   if (InserPositionNode == InsertOpcodeNode) {
 //
@@ -741,6 +744,8 @@ CFormPkg::AdjustDynamicInsertOpcode (
   // Insert the last restore data node.
   //
   TmpNode = GetNodeBefore (InsertOpcodeNode);
+  assert (TmpNode != NULL);
+
   if (TmpNode == InserPositionNode) {
 NewRestoreNodeBegin->mNext = NewRestoreNodeEnd;
   } else {
@@ -790,6 +795,8 @@ CFormPkg::AdjustDynamicInsertOpcode (
   mBufferNodeQueueTail = NewLastEndNode;
 } else if (mBufferNodeQueueTail->mBufferFree - 
mBufferNodeQueueTail->mBufferStart == 2) {
   TmpNode = GetNodeBefore(mBufferNodeQueueTail);
+  assert (TmpNode != NULL);
+
   TmpNode->mNext = NewRestoreNodeBegin;
   if (NewRestoreNodeEnd != NULL) {
 NewRestoreNodeEnd->mNext = mBufferNodeQueueTail;
@@ -1314,7 +1321,7 @@ CIfrRecordInfoDB::IfrAdjustDynamicOpcodeInRecords (
   //
   // Check the nodes whether exist.
   //
-  if (pNodeBeforeDynamic == NULL || pAdjustNode == NULL) {
+  if (pNodeBeforeDynamic == NULL || pAdjustNode == NULL || pNodeBeforeAdjust 
== NULL) {
 return FALSE;
   }
 
@@ -1854,6 +1861,10 @@ CIfrRecordInfoDB::IfrCreateDefaultForQuestion (
   pSNode = pSNode->mNext;
   OpcodeCount++;
 }
+
+assert (pSNode);
+assert (pENode);
+
 //
 // Record the offset of node which need to be adjust, will move the new 
created default opcode to this offset.
 //
@@ -1875,6 +1886,7 @@ CIfrRecordInfoDB::IfrCreateDefaultForQuestion (
 while (pSNode != NULL && pSNode->mNext != NULL && OpcodeNumber-- != 0) 
{
   pOpHead = (EFI_IFR_OP_HEADER *) pSNode->mIfrBinBuf;
   Obj = new CIfrObj (pOpHead->OpCode, NULL, pSNode->mBinBufLen, FALSE);
+  assert (Obj != NULL);
   Obj->SetLineNo (pSNode->mLineNo);
   ObjBinBuf = Obj->GetObjBinAddr();
   memcpy (ObjBinBuf, pSNode->mIfrBinBuf, (UINTN)pSNode->mBinBufLen);
@@ -2378,6 +2390,8 @@ CIfrObj::CIfrObj (
   mObjBinBuf   = ((DelayEmit == FALSE) && (gCreateOp == TRUE)) ? 
gCFormPkg.IfrBinBufferGet (mObjBinLen) : new CHAR8[EFI_IFR_MAX_LENGTH];
   mRecordIdx   = (gCreateOp == TRUE) ? gCIfrRecordInfoDB.IfrRecordRegister 
(0x, mObjBinBuf, mObjBinLen, mPkgOffset) : 
EFI_IFR_RECORDINFO_IDX_INVALUD;
 
+  assert (mObjBinBuf != NULL);
+
   if (IfrObj != NULL) {
 *IfrObj= mObjBinBuf;
   }
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp 
b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index b3d1ac5..d2cb5cc 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -665,7 +665,7 @@ CVfrVarDataTypeDB::GetTypeField (
 {
   SVfrDataField  *pField = NULL;
 
-  if ((FName == NULL) && (Type == NULL)) {
+  if ((FName == NULL) || (Type == NULL)) {
 return VFR_RETURN_FATAL_ERROR;
   }
 
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 11/52] BaseTools/VolInfo: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 46 
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c 
b/BaseTools/Source/C/VolInfo/VolInfo.c
index 3a2686a..1ea2f49 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -265,6 +265,10 @@ Returns:
 OpenSslPath = OpenSslCommand;
   } else {
 OpenSslPath = malloc(strlen(OpenSslEnv)+strlen(OpenSslCommand)+1);
+if (OpenSslPath == NULL) {
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  return GetUtilityStatus ();
+}
 CombinePath(OpenSslEnv, OpenSslCommand, OpenSslPath);
   }
   if (OpenSslPath == NULL){
@@ -1623,9 +1627,11 @@ Returns:
 SectionHeaderLen = GetSectionHeaderLength((EFI_COMMON_SECTION_HEADER 
*)Ptr);
 
 SectionName = SectionNameToStr (Type);
-printf ("\n");
-printf ("  Type:  %s\n  Size:  0x%08X\n", SectionName, (unsigned) 
SectionLength);
-free (SectionName);
+if (SectionName != NULL) {
+  printf 
("\n");
+  printf ("  Type:  %s\n  Size:  0x%08X\n", SectionName, (unsigned) 
SectionLength);
+  free (SectionName);
+}
 
 switch (Type) {
 case EFI_SECTION_RAW:
@@ -1653,6 +1659,10 @@ Returns:
   strlen (ToolOutputFileName) +
   1
   );
+if (SystemCommand == NULL) {
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  return EFI_OUT_OF_RESOURCES;
+}
 sprintf (
   SystemCommand,
   SystemCommandFormatString,
@@ -1678,12 +1688,18 @@ Returns:
 nFileLen = ftell(fp);
 fseek(fp,0,SEEK_SET);
 StrLine = malloc(nFileLen);
+if (StrLine == NULL) {
+  fclose(fp);
+  free (SystemCommand);
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  return EFI_OUT_OF_RESOURCES;
+}
 fgets(StrLine, nFileLen, fp);
 NewStr = strrchr (StrLine, '=');
 printf ("  SHA1: %s\n", NewStr + 1);
 free (StrLine);
+fclose(fp);
   }
-  fclose(fp);
 }
 remove(ToolInputFileName);
 remove(ToolOutputFileName);
@@ -1845,6 +1861,19 @@ Returns:
 close(fd2);
#endif
 
+if ((ToolInputFile == NULL) || (ToolOutputFile == NULL)) {
+  if (ToolInputFile != NULL) {
+free (ToolInputFile);
+  }
+  if (ToolOutputFile != NULL) {
+free (ToolOutputFile);
+  }
+  free (ExtractionTool);
+
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  return EFI_OUT_OF_RESOURCES;
+}
+
 //
 // Construction 'system' command string
 //
@@ -1856,6 +1885,14 @@ Returns:
   strlen (ToolOutputFile) +
   1
   );
+if (SystemCommand == NULL) {
+  free (ToolInputFile);
+  free (ToolOutputFile);
+  free (ExtractionTool);
+
+  Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+  return EFI_OUT_OF_RESOURCES;
+}
 sprintf (
   SystemCommand,
   SystemCommandFormatString,
@@ -1884,6 +1921,7 @@ Returns:
 );
 remove (ToolOutputFile);
 free (ToolOutputFile);
+free (SystemCommand);
 if (EFI_ERROR (Status)) {
   Error (NULL, 0, 0004, "unable to read decoded GUIDED section", NULL);
   return EFI_SECTION_ERROR;
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 04/52] BaseTools/GenFv: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenFv/GenFvInternalLib.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index fab7c94..f7e3ba5 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -1,7 +1,7 @@
 /** @file
 This file contains the internal functions required to generate a Firmware 
Volume.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
 Portions Copyright (c) 2016 HP Development Company, L.P.
 This program and the accompanying materials  
@@ -2494,6 +2494,10 @@ Returns:
 // Open the FV Extension Header file
 //
 FvExtHeaderFile = fopen (LongFilePath (mFvDataInfo.FvExtHeaderFile), "rb");
+if (FvExtHeaderFile == NULL) {
+  Error (NULL, 0, 0001, "Error opening file", mFvDataInfo.FvExtHeaderFile);
+  return EFI_ABORTED;
+}
 
 //
 // Get the file size
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 13/52] BaseTools/VfrCompile: Initialize local variables before being used

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp| 4 +++-
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp 
b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index aa27ce0..124b8e8 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -825,7 +825,7 @@ CFormPkg::DeclarePendingQuestion (
   CHAR8  FName[MAX_NAME_LEN];
   CHAR8  *SName;
   CHAR8  *NewStr;
-  UINT32 ShrinkSize;
+  UINT32 ShrinkSize = 0;
   EFI_VFR_RETURN_CODE  ReturnCode;
   EFI_VFR_VARSTORE_TYPE VarStoreType  = EFI_VFR_VARSTORE_INVALID;
   EFI_VARSTORE_ID   VarStoreId= EFI_VARSTORE_ID_INVALID;
@@ -1297,6 +1297,7 @@ CIfrRecordInfoDB::IfrAdjustDynamicOpcodeInRecords (
   SIfrRecord *pAdjustNode, *pNodeBeforeAdjust;
   SIfrRecord *pNodeBeforeDynamic;
 
+  pPreNode= NULL;
   pAdjustNode = NULL;
   pNodeBeforeDynamic  = NULL;
   OpcodeOffset= 0;
@@ -1845,6 +1846,7 @@ CIfrRecordInfoDB::IfrCreateDefaultForQuestion (
 // Point to the first expression opcode.
 //
 pSNode = pDefaultNode->mNext;
+pENode = NULL;
 ScopeCount++;
 //
 // Get opcode number behind the EFI_IFR_DEFAULT_2 until reach its END 
opcode (including the END opcode of EFI_IFR_DEFAULT_2)
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp 
b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index d2cb5cc..1ab95be 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -1328,7 +1328,7 @@ SVfrVarStorageNode::SVfrVarStorageNode (
   if (Guid != NULL) {
 mGuid = *Guid;
   } else {
-memset (&Guid, 0, sizeof (EFI_GUID));
+memset (&mGuid, 0, sizeof (EFI_GUID));
   }
   if (StoreName != NULL) {
 mVarStoreName = new CHAR8[strlen(StoreName) + 1];
@@ -1355,7 +1355,7 @@ SVfrVarStorageNode::SVfrVarStorageNode (
   if (Guid != NULL) {
 mGuid = *Guid;
   } else {
-memset (&Guid, 0, sizeof (EFI_GUID));
+memset (&mGuid, 0, sizeof (EFI_GUID));
   }
   if (StoreName != NULL) {
 mVarStoreName = new CHAR8[strlen(StoreName) + 1];
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 12/52] BaseTools/TianoCompress: Initialize local variables before being used

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/TianoCompress/TianoCompress.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c 
b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index 57253cc..b994d93 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -2153,7 +2153,7 @@ Returns:
   UINT16  Start[18];
   UINT16  *Pointer;
   UINT16  Index3;
-  volatile UINT16  Index;
+  UINT16  Index;
   UINT16  Len;
   UINT16  Char;
   UINT16  JuBits;
@@ -2163,7 +2163,7 @@ Returns:
   UINT16  WordOfStart;
   UINT16  WordOfCount;
 
-  for (Index = 1; Index <= 16; Index++) {
+  for (Index = 0; Index <= 16; Index++) {
 Count[Index] = 0;
   }
 
@@ -2171,6 +2171,7 @@ Returns:
 Count[BitLen[Index]]++;
   }
 
+  Start[0] = 0;
   Start[1] = 0;
 
   for (Index = 1; Index <= 16; Index++) {
@@ -2188,6 +2189,7 @@ Returns:
 
   JuBits = (UINT16) (16 - TableBits);
 
+  Weight[0] = 0;
   for (Index = 1; Index <= TableBits; Index++) {
 Start[Index] >>= JuBits;
 Weight[Index] = (UINT16) (1U << (TableBits - Index));
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 14/52] BaseTools/GenBootSector: Fix parameter format mismatch in printf functions

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenBootSector/GenBootSector.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/C/GenBootSector/GenBootSector.c 
b/BaseTools/Source/C/GenBootSector/GenBootSector.c
index c218548..efdfcd2 100644
--- a/BaseTools/Source/C/GenBootSector/GenBootSector.c
+++ b/BaseTools/Source/C/GenBootSector/GenBootSector.c
@@ -4,7 +4,7 @@ Reading/writing MBR/DBR.
 If we write MBR to disk, we just update the MBR code and the partition 
table wouldn't be over written.
 If we process DBR, we will patch MBR to set first partition active if no 
active partition exists.
 
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -169,7 +169,7 @@ Return:
   stderr, 
   "error E0005: CreateFile failed: Volume = %s, LastError = 0x%x\n", 
   VolumeAccessPath, 
-  GetLastError ()
+  (unsigned) GetLastError ()
   );
 return FALSE;
   }
@@ -599,7 +599,7 @@ GetPathInfo (
 }
 
 if (!GetDriveInfo(VolumeLetter, &DriveInfo)) {
-  fprintf (stderr, "ERROR: GetDriveInfo - 0x%x\n", GetLastError ());
+  fprintf (stderr, "ERROR: GetDriveInfo - 0x%x\n", (unsigned) GetLastError 
());
   return ErrorPath;
 }
 
@@ -792,7 +792,7 @@ main (
   (OutputPathInfo.Type != PathFile) ? "Write" : "Read", 
   ProcessMbr ? "MBR" : "DBR", 
   ErrorStatusDesc[Status],
-  GetLastError ()
+  (unsigned) GetLastError ()
   );
 return 1;
   }
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 09/52] BaseTools/TianoCompress: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/TianoCompress/TianoCompress.c | 37 
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c 
b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index 70f1b61..57253cc 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -5,7 +5,7 @@ and Pointers to repeated strings.
 This sequence is further divided into Blocks and Huffman codings are applied 
to 
 each Block.
   
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -240,6 +240,10 @@ Returns:
   UINT32  Index;
 
   mText = malloc (WNDSIZ * 2 + MAXMATCH);
+  if (mText == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return EFI_OUT_OF_RESOURCES;
+  }
   for (Index = 0; Index < WNDSIZ * 2 + MAXMATCH; Index++) {
 mText[Index] = 0;
   }
@@ -250,6 +254,11 @@ Returns:
   mParent = malloc (WNDSIZ * 2 * sizeof (*mParent));
   mPrev   = malloc (WNDSIZ * 2 * sizeof (*mPrev));
   mNext   = malloc ((MAX_HASH_VAL + 1) * sizeof (*mNext));
+  if (mLevel == NULL || mChildCount == NULL || mPosition == NULL ||
+mParent == NULL || mPrev == NULL || mNext == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return EFI_OUT_OF_RESOURCES;
+  }
 
   mBufSiz = BLKSIZ;
   mBuf= malloc (mBufSiz);
@@ -1911,20 +1920,18 @@ Returns:
 free(FileBuffer);
 return 1;
   }
-   
-  if (OutputFileName != NULL) {
-OutputFile = fopen (LongFilePath (OutputFileName), "wb");
-if (OutputFile == NULL) {
-  Error (NULL, 0, 0001, "Error opening output file for writing", 
OutputFileName);
+
+  if (OutputFileName == NULL) {
+OutputFileName = DEFAULT_OUTPUT_FILE;
+  }
+  OutputFile = fopen (LongFilePath (OutputFileName), "wb");
+  if (OutputFile == NULL) {
+Error (NULL, 0, 0001, "Error opening output file for writing", 
OutputFileName);
 if (InputFile != NULL) {
   fclose (InputFile);
-  }
-  goto ERROR;
-  }
-} else {
-  OutputFileName = DEFAULT_OUTPUT_FILE;
-  OutputFile = fopen (LongFilePath (OutputFileName), "wb");
 }
+goto ERROR;
+  }
 
   if (ENCODE) {
   //
@@ -1942,12 +1949,18 @@ Returns:
   goto ERROR;
 }
   }
+
   Status = TianoCompress ((UINT8 *)FileBuffer, InputLength, OutBuffer, 
&DstSize);
   if (Status != EFI_SUCCESS) {
 Error (NULL, 0, 0007, "Error compressing file", NULL);
 goto ERROR;
   }
 
+  if (OutBuffer == NULL) {
+Error (NULL, 0, 4001, "Resource:", "Memory cannot be allocated!");
+goto ERROR;
+  }
+
   fwrite(OutBuffer,(size_t)DstSize, 1, OutputFile);
   free(Scratch);
   free(FileBuffer);
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 00/52] Resolve issues for C source codes in BaseTools

2016-10-12 Thread Hao Wu
The patch series fixes the following types of issues for C source codes in
BaseTools:

1. Avoid possible NULL pointer dereference
2. Initialize local variables before use
3. Remove unused local variables
4. Avoid accessing over array bounds
5. Resolve possible memory leak
6. Resolve file handles not being closed
7. Resolve possible buffer overflow in printf/scanf functions

The patch series is also available at:
https://github.com/hwu25/edk2/tree/BaseTools_V1

Cc: Liming Gao 
Cc: Yonghong Zhu 
Cc: Eric Dong 
Cc: Dandan Bi 

Hao Wu (52):
  BaseTools/C/Common: Avoid possible NULL pointer dereference
  BaseTools/EfiRom: Avoid possible NULL pointer dereference
  BaseTools/GenFfs: Avoid possible NULL pointer dereference
  BaseTools/GenFv: Avoid possible NULL pointer dereference
  BaseTools/GenFw: Avoid possible NULL pointer dereference
  BaseTools/GenPage: Avoid possible NULL pointer dereference
  BaseTools/GenSec: Avoid possible NULL pointer dereference
  BaseTools/GenVtf: Avoid possible NULL pointer dereference
  BaseTools/TianoCompress: Avoid possible NULL pointer dereference
  BaseTools/VfrCompile: Avoid possible NULL pointer dereference
  BaseTools/VolInfo: Avoid possible NULL pointer dereference
  BaseTools/TianoCompress: Initialize local variables before being used
  BaseTools/VfrCompile: Initialize local variables before being used
  BaseTools/GenBootSector: Fix parameter format mismatch in printf
functions
  BaseTools/VolInfo: Fix parameter format mismatch in printf functions
  BaseTools/C/Common: Fix parameter format mismatch in scanf functions
  BaseTools/GenFv: Fix parameter format mismatch in scanf functions
  BaseTools/GenFw: Fix parameter format mismatch in scanf functions
  BaseTools/GenVtf: Fix parameter format mismatch in scanf functions
  BaseTools/C/Common: Fix potential access over array bounds
  BaseTools/EfiRom: Fix potential access over array bounds
  BaseTools/GenFv: Fix potential access over array bounds
  BaseTools/TianoCompress: Fix potential access over array bounds
  BaseTools/VfrCompile: Fix potential access over array bounds
  BaseTools/VfrCompile: Avoid freeing memory with mismatched functions
  BaseTools/VfrCompile: Add assignment operator definition for some
classes
  BaseTools/VfrCompile: Avoid freeing freed memory in classes
  BaseTools/VfrCompile: Remove unused local variables
  BaseTools/C/Common: Fix potential memory leak
  BaseTools/EfiRom: Fix potential memory leak
  BaseTools/GenFv: Fix potential memory leak
  BaseTools/GenPage: Fix potential memory leak
  BaseTools/GenSec: Fix potential memory leak
  BaseTools/GenVtf: Fix potential memory leak
  BaseTools/Split: Fix potential memory and resource leak
  BaseTools/TianoCompress: Fix potential memory leak
  BaseTools/VfrCompile: Fix potential memory leak
  BaseTools/VolInfo: Fix potential memory leak
  BaseTools/EfiRom: Fix file handles not being closed
  BaseTools/GenBootSector: Fix file handles not being closed
  BaseTools/GenCrc32: Fix file handles not being closed
  BaseTools/GenFv: Fix file handles not being closed
  BaseTools/GenVtf: Fix file handles not being closed
  BaseTools/LzmaCompress: Fix file handles not being closed
  BaseTools/TianoCompress: Fix file handles not being closed
  BaseTools/VolInfo: Fix file handles not being closed
  BaseTools/GenVtf: Fix potential buffer overflow in scanf functions
  BaseTools/VolInfo: Fix potential buffer overflow in scanf functions
  BaseTools/VfrCompile: Explicitly state format string for DebugMsg()
  BaseTools/VolInfo: Use hard-coded format string for calls to sprintf()
  BaseTools/VfrCompile/Pccts: Add virtual destructor for class
DLGInputStream
  BaseTools/VfrCompile/Pccts: Make assignment operator not returning
void

 BaseTools/Source/C/Common/BasePeCoff.c |  12 ++
 BaseTools/Source/C/Common/CommonLib.c  |   8 +-
 BaseTools/Source/C/Common/Decompress.c |  41 --
 BaseTools/Source/C/Common/EfiUtilityMsgs.c |  20 +--
 BaseTools/Source/C/Common/FirmwareVolumeBuffer.c   |   6 +-
 BaseTools/Source/C/Common/MemoryFile.c |   3 +-
 BaseTools/Source/C/Common/MyAlloc.c|  55 +++-
 .../Source/C/Common/ParseGuidedSectionTools.c  |  21 ++--
 BaseTools/Source/C/Common/ParseInf.c   |  24 ++--
 BaseTools/Source/C/Common/SimpleFileParsing.c  |  14 +--
 BaseTools/Source/C/Common/TianoCompress.c  |   9 +-
 BaseTools/Source/C/EfiRom/EfiRom.c | 120 --
 BaseTools/Source/C/GenBootSector/GenBootSector.c   |  43 ---
 BaseTools/Source/C/GenCrc32/GenCrc32.c |   3 +-
 BaseTools/Source/C/GenFfs/GenFfs.c |  36 +++---
 BaseTools/Source/C/GenFv/GenFv.c   |   9 +-
 BaseTools/Source/C/GenFv/GenFvInternalLib.c|  83 ++--
 BaseTools/Source/C/GenFw/Elf32Convert.c|   8 ++
 BaseTools/Source/C/GenFw/Elf64Convert.c|  10 +-
 BaseTools/Source/C/GenFw/ElfConvert.c 

[edk2] [PATCH 03/52] BaseTools/GenFfs: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenFfs/GenFfs.c | 36 +++-
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c 
b/BaseTools/Source/C/GenFfs/GenFfs.c
index 433b608..25a722a 100644
--- a/BaseTools/Source/C/GenFfs/GenFfs.c
+++ b/BaseTools/Source/C/GenFfs/GenFfs.c
@@ -1,7 +1,7 @@
 /** @file
 This file contains functions required to generate a Firmware File System file.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -842,7 +842,7 @@ Returns:
);
   }
 
-  if (EFI_ERROR (Status)) {
+  if (EFI_ERROR (Status) || (FileBuffer == NULL)) {
 goto Finish;
   }
   
@@ -915,22 +915,24 @@ Returns:
   //
   // Open output file to write ffs data.
   //
-  remove(OutputFileName);
-  FfsFile = fopen (LongFilePath (OutputFileName), "wb");
-  if (FfsFile == NULL) {
-Error (NULL, 0, 0001, "Error opening file", OutputFileName);
-goto Finish;
-  }
-  //
-  // write header
-  //
-  fwrite (&FfsFileHeader, 1, HeaderSize, FfsFile);
-  //
-  // write data
-  //
-  fwrite (FileBuffer, 1, FileSize - HeaderSize, FfsFile);
+  if (OutputFileName != NULL) {
+remove(OutputFileName);
+FfsFile = fopen (LongFilePath (OutputFileName), "wb");
+if (FfsFile == NULL) {
+  Error (NULL, 0, 0001, "Error opening file", OutputFileName);
+  goto Finish;
+}
+//
+// write header
+//
+fwrite (&FfsFileHeader, 1, HeaderSize, FfsFile);
+//
+// write data
+//
+fwrite (FileBuffer, 1, FileSize - HeaderSize, FfsFile);
 
-  fclose (FfsFile);
+fclose (FfsFile);
+  }
 
 Finish:
   if (InputFileName != NULL) {
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 06/52] BaseTools/GenPage: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenPage/GenPage.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/GenPage/GenPage.c 
b/BaseTools/Source/C/GenPage/GenPage.c
index fb829e6..5bf8bf8 100644
--- a/BaseTools/Source/C/GenPage/GenPage.c
+++ b/BaseTools/Source/C/GenPage/GenPage.c
@@ -15,7 +15,7 @@
   Directory-Ptr Directory {512}
 ) {4}
 
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -146,6 +146,10 @@ Return:
   X64_PAGE_TABLE_ENTRY_2M   *PageDirectoryEntry2MB;
 
   PageTable = (void *)malloc (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE);
+  if (PageTable == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return NULL;
+  }
   memset (PageTable, 0, (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE));
   PageTablePtr = PageTable;
 
@@ -417,6 +421,10 @@ main (
   // Create X64 page table
   //
   BaseMemory = CreateIdentityMappingPageTables ();
+  if (BaseMemory == NULL) {
+Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+return STATUS_ERROR;
+  }
 
   //
   // Add page table to binary file
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 07/52] BaseTools/GenSec: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/GenSec/GenSec.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/GenSec/GenSec.c 
b/BaseTools/Source/C/GenSec/GenSec.c
index 20b2a10..583ff1d 100644
--- a/BaseTools/Source/C/GenSec/GenSec.c
+++ b/BaseTools/Source/C/GenSec/GenSec.c
@@ -1,7 +1,7 @@
 /** @file
 Creates output file that is a properly formed section per the PI spec.
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -667,6 +667,10 @@ Returns:
 return Status;
   }
 
+  if (FileBuffer == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
   CompressFunction = NULL;
 
   //
@@ -731,6 +735,10 @@ Returns:
 
   return Status;
 }
+
+if (FileBuffer == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
   }
 
   DebugMsg (NULL, 0, 9, "comprss file size", 
@@ -889,6 +897,10 @@ Returns:
 return Status;
   }
 
+  if (FileBuffer == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
   if (InputLength == 0) {
 Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s 
can't be zero", InputFileName);
 return EFI_NOT_FOUND;
@@ -1365,7 +1377,9 @@ Returns:
   //
   // GuidValue is only required by Guided section.
   //
-  if ((SectType != EFI_SECTION_GUID_DEFINED) && (CompareGuid (&VendorGuid, 
&mZeroGuid) != 0)) {
+  if ((SectType != EFI_SECTION_GUID_DEFINED) &&
+(SectionName != NULL) &&
+(CompareGuid (&VendorGuid, &mZeroGuid) != 0)) {
 fprintf (stdout, "Warning: the input guid value is not required for this 
section type %s\n", SectionName);
   }
   
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 02/52] BaseTools/EfiRom: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/EfiRom/EfiRom.c | 38 --
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c 
b/BaseTools/Source/C/EfiRom/EfiRom.c
index 7a57912..32aa3dc 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.c
+++ b/BaseTools/Source/C/EfiRom/EfiRom.c
@@ -1,7 +1,7 @@
 /** @file
 Utility program to create an EFI option ROM image from binary and EFI PE32 
files.
 
-Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials are licensed and made available 
 under the terms and conditions of the BSD License which accompanies this 
 distribution.  The full text of the license may be found at
@@ -95,24 +95,26 @@ Returns:
   // the command line, or the first input filename with a different extension.
   //
   if (!mOptions.OutFileName[0]) {
-strcpy (mOptions.OutFileName, mOptions.FileList->FileName);
-//
-// Find the last . on the line and replace the filename extension with
-// the default
-//
-for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;
- (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');
- Ext--
-)
-  ;
-//
-// If dot here, then insert extension here, otherwise append
-//
-if (*Ext != '.') {
-  Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);
-}
+if (mOptions.FileList != NULL) {
+  strcpy (mOptions.OutFileName, mOptions.FileList->FileName);
+  //
+  // Find the last . on the line and replace the filename extension with
+  // the default
+  //
+  for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;
+   (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');
+   Ext--
+  )
+;
+  //
+  // If dot here, then insert extension here, otherwise append
+  //
+  if (*Ext != '.') {
+Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);
+  }
 
-strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);
+  strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);
+}
   }
   //
   // Make sure we don't have the same filename for input and output files
-- 
1.9.5.msysgit.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 01/52] BaseTools/C/Common: Avoid possible NULL pointer dereference

2016-10-12 Thread Hao Wu
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu 
---
 BaseTools/Source/C/Common/BasePeCoff.c | 12 +
 BaseTools/Source/C/Common/EfiUtilityMsgs.c | 20 
 BaseTools/Source/C/Common/FirmwareVolumeBuffer.c   |  5 +-
 BaseTools/Source/C/Common/MyAlloc.c| 55 --
 .../Source/C/Common/ParseGuidedSectionTools.c  | 15 +++---
 BaseTools/Source/C/Common/TianoCompress.c  |  9 +++-
 6 files changed, 93 insertions(+), 23 deletions(-)

diff --git a/BaseTools/Source/C/Common/BasePeCoff.c 
b/BaseTools/Source/C/Common/BasePeCoff.c
index d0cc1af..9adbdfa 100644
--- a/BaseTools/Source/C/Common/BasePeCoff.c
+++ b/BaseTools/Source/C/Common/BasePeCoff.c
@@ -650,6 +650,10 @@ Returns:
 ImageContext,
 RelocDir->VirtualAddress + RelocDir->Size - 1
 );
+if (RelocBase == NULL || RelocBaseEnd == NULL || RelocBaseEnd < 
RelocBase) {
+  ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+  return RETURN_LOAD_ERROR;
+}
   } else {
 //
 // Set base and end to bypass processing below.
@@ -674,6 +678,10 @@ Returns:
 ImageContext,
 RelocDir->VirtualAddress + RelocDir->Size - 1
 );
+if (RelocBase == NULL || RelocBaseEnd == NULL || RelocBaseEnd < 
RelocBase) {
+  ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+  return RETURN_LOAD_ERROR;
+}
   } else {
 //
 // Set base and end to bypass processing below.
@@ -710,6 +718,10 @@ Returns:
 RelocEnd  = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
 if (!(ImageContext->IsTeImage)) {
   FixupBase = PeCoffLoaderImageAddress (ImageContext, 
RelocBase->VirtualAddress);
+  if (FixupBase == NULL) {
+ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+return RETURN_LOAD_ERROR;
+  }
 } else {
   FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
 RelocBase->VirtualAddress +
diff --git a/BaseTools/Source/C/Common/EfiUtilityMsgs.c 
b/BaseTools/Source/C/Common/EfiUtilityMsgs.c
index 438f338..7b4c231 100644
--- a/BaseTools/Source/C/Common/EfiUtilityMsgs.c
+++ b/BaseTools/Source/C/Common/EfiUtilityMsgs.c
@@ -1,7 +1,7 @@
 /** @file
 EFI tools utility functions to display warning, error, and informational 
messages
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -451,14 +451,16 @@ Notes:
 //
 time (&CurrentTime);
 NewTime = localtime (&CurrentTime);
-fprintf (stdout, "%04d-%02d-%02d %02d:%02d:%02d",
- NewTime->tm_year + 1900,
- NewTime->tm_mon + 1,
- NewTime->tm_mday,
- NewTime->tm_hour,
- NewTime->tm_min,
- NewTime->tm_sec
- );
+if (NewTime != NULL) {
+  fprintf (stdout, "%04d-%02d-%02d %02d:%02d:%02d",
+   NewTime->tm_year + 1900,
+   NewTime->tm_mon + 1,
+   NewTime->tm_mday,
+   NewTime->tm_hour,
+   NewTime->tm_min,
+   NewTime->tm_sec
+   );
+}
 if (Cptr != NULL) {
   sprintf (Line, ": %s", Cptr);
   if (LineNumber != 0) {
diff --git a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c 
b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
index 7988d8e..a287fe1 100644
--- a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
+++ b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
@@ -1,7 +1,7 @@
 /** @file
 EFI Firmware Volume routines which work on a Fv image in buffers.
 
-Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -353,6 +353,9 @@ Returns:
 
   if (*DestinationFv == NULL) {
 *DestinationFv = CommonLibBinderAllocate (size);
+if (*DestinationFv == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
   }
 
   CommonLibBinderCopyMem (*DestinationFv, SourceFv, size);
diff --git a/BaseTools/Source/C/Common/MyAlloc.c 
b/BaseTools/Source/C/Common/MyAlloc.c
index eabba57..be7c515 100644
--- a/BaseTools/Source/C/Common/MyAlloc.c
+++ b/BaseTools/Source/C/Common/MyAlloc.c
@@ -1,7 +1,7 @@
 /** @file
 File for memory

Re: [edk2] ArmPlatformPkg: Allocate VRAM as RuntimeServicesData

2016-10-12 Thread Evan Lloyd
Hi Ryan.
No, this is dead.
Ard's rebuttal was spot on, and unarguable.   The problem needs fixing, but not 
in UEFI.
Please disregard this patch.

Regards,
Evan


>-Original Message-
>From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
>Sent: 11 October 2016 20:17
>To: ryan.har...@linaro.org
>Cc: Evan Lloyd; edk2-devel@lists.01.org; Leif Lindholm
>Subject: Re: [edk2] ArmPlatformPkg: Allocate VRAM as
>RuntimeServicesData
>
>On 11 October 2016 at 18:44, Ryan Harkin  wrote:
>> Hi Evan,
>>
>> This was sent to the list with no subject line and I wasn't on CC, so
>> I didn't see it.
>>
>> Are you still using this patch and want it in, i.e. does it need
>> review and test?
>>
>
>I'm sure it works, but I don't think we should take it.
>RuntimeServicesData can never be released to the OS, so taking an 8MB
>chunk just in case the OS may decide to drive the framebuffer using
>the firmware's protocol rather than via a native driver is not
>something we should have in reference code.
>
>The GOP protocol is arguably a hack anyway, since the entire protocol
>database and driver tree are torn down after ExitBootServices(), while
>the GOP leaves a live memory range in place that happens to keep
>operating as a framebuffer. If the OS wants to use this protocol
>during normal operation, it should take care to reserve this memory
>region itself.
>
>I am aware that not all OSes may behave correctly in this regard. This
>is mainly due to the fact that GOP is usually implemented by a PCI
>device, which exposes the framebuffer via a PCI BAR rather than via a
>system memory range.
>
>
>
>> On 4 March 2016 at 15:57,   wrote:
>>> Code at: https://github.com/EvanLloyd/tianocore/commit/
>>> From: Sami Mujawar 
>>> Date: Thu, 25 Feb 2016 15:07:40 +
>>> Subject: [PATCH] ArmPlatformPkg: Allocate VRAM as
>RuntimeServicesData
>>>
>>> The UEFI specification allows the operating system (OS) to use the
>>> Graphics Output Protocol (GOP) in the following scenarios:
>>>  a. as part of the startup process and
>>>  b. prior to loading of a high performance OS graphics driver
>>>
>>> If the VRAM is allocated as BootServicesData, then it is unmapped on
>>> exit boot services. This prevents GOP usage by the OS post exit boot
>>> services (the second scenario); as it results in a crash when the VRAM
>>> is accessed.
>>>
>>> This patch fixes the issue by allocating VRAM as RuntimeServicesData.
>>>
>>> Code at:
>https://github.com/EvanLloyd/tianocore/commit/18fab16a63c59c84c71cd81
>089a55a4081ebe253
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Alexei Fedorov 
>>> Signed-off-by: Girish Pathak 
>>> Signed-off-by: Sami Mujawar 
>>> Signed-off-by: Evan Lloyd 
>>> ---
>>>
>ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
>mVExpress.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git
>a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>ArmVExpress.c
>b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>ArmVExpress.c
>>> index a578467..4ab8862 100644
>>> ---
>a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>ArmVExpress.c
>>> +++
>b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>ArmVExpress.c
>>> @@ -133,7 +133,7 @@ LcdPlatformGetVram (
>>>} else {
>>>  AllocationType = AllocateAddress;
>>>}
>>> -  Status = gBS->AllocatePages (AllocationType, EfiBootServicesData,
>EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
>>> +  Status = gBS->AllocatePages (AllocationType, EfiRuntimeServicesData,
>EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
>>>if (EFI_ERROR(Status)) {
>>>  return Status;
>>>}
>>> --
>>> 2.7.0
>>>
>>> ___
>>> edk2-devel mailing list
>>> edk2-devel@lists.01.org
>>> https://lists.01.org/mailman/listinfo/edk2-devel
>> ___
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] Format a volume in UEFI (or delete all files)

2016-10-12 Thread GN Keshava
Hi all,

I need to format fs1: (or delete all files and folders in root directory)
from my UEFI application.

I'm able to use file system APIs such as Open, Write or Delete too. But
Delete API needs File (file path) as argument, but what I want is delete
all files (irrespective of file name).

What could be the best method? Is there any API to directly delete all
files? If not, How to go through (Open) all files and delete each?

How I can get each file and folder names in a directory programmatically ?

Thanks.
With regards,
Keshava
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 0/5] OvmfPkg/QemuVideoDxe: cleanups and tweaks

2016-10-12 Thread Laszlo Ersek
Reviewing (part of) Ray's recent FrameBufferBltLib changes gave me the
idea for this. The patches are really small.

Public branch: .

Cc: Jordan Justen 

Thanks
Laszlo

Laszlo Ersek (5):
  OvmfPkg/QemuVideoDxe: drop useless QEMU_VIDEO_MODE_DATA.RefreshRate
  OvmfPkg/QemuVideoDxe: drop QEMU_VIDEO_CIRRUS_MODES.RefreshRate
  OvmfPkg/QemuVideoDxe: remove useless
QEMU_VIDEO_PRIVATE_DATA.CurrentMode
  OvmfPkg/QemuVideoDxe: remove useless
QEMU_VIDEO_PRIVATE_DATA.LineBuffer
  OvmfPkg/QemuVideoDxe: upgrade VERBOSE debug messages to INFO

 OvmfPkg/QemuVideoDxe/Qemu.h   |  9 ++
 OvmfPkg/QemuVideoDxe/Gop.c| 16 ---
 OvmfPkg/QemuVideoDxe/Initialize.c | 30 +---
 OvmfPkg/QemuVideoDxe/VbeShim.c|  4 +--
 4 files changed, 17 insertions(+), 42 deletions(-)

-- 
2.9.2

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 1/5] OvmfPkg/QemuVideoDxe: drop useless QEMU_VIDEO_MODE_DATA.RefreshRate

2016-10-12 Thread Laszlo Ersek
This field is never used beyond assignment and debug-logging. Remove it.

Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---
 OvmfPkg/QemuVideoDxe/Qemu.h   |  1 -
 OvmfPkg/QemuVideoDxe/Initialize.c | 12 
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h
index 5844bc404cef..7c1f80c772e3 100644
--- a/OvmfPkg/QemuVideoDxe/Qemu.h
+++ b/OvmfPkg/QemuVideoDxe/Qemu.h
@@ -54,11 +54,10 @@
 typedef struct {
   UINT32  InternalModeIndex; // points into card-specific mode table
   UINT32  HorizontalResolution;
   UINT32  VerticalResolution;
   UINT32  ColorDepth;
-  UINT32  RefreshRate;
 } QEMU_VIDEO_MODE_DATA;
 
 #define PIXEL_RED_SHIFT   0
 #define PIXEL_GREEN_SHIFT 3
 #define PIXEL_BLUE_SHIFT  6
diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c 
b/OvmfPkg/QemuVideoDxe/Initialize.c
index 9e0c3aa09fd6..b12253ba5892 100644
--- a/OvmfPkg/QemuVideoDxe/Initialize.c
+++ b/OvmfPkg/QemuVideoDxe/Initialize.c
@@ -184,19 +184,17 @@ QemuVideoCirrusModeSetup (
   for (Index = 0; Index < QEMU_VIDEO_CIRRUS_MODE_COUNT; Index ++) {
 ModeData->InternalModeIndex = Index;
 ModeData->HorizontalResolution  = VideoMode->Width;
 ModeData->VerticalResolution= VideoMode->Height;
 ModeData->ColorDepth= VideoMode->ColorDepth;
-ModeData->RefreshRate   = VideoMode->RefreshRate;
 DEBUG ((EFI_D_INFO,
-  "Adding Mode %d as Cirrus Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
+  "Adding Mode %d as Cirrus Internal Mode %d: %dx%d, %d-bit\n",
   (INT32) (ModeData - Private->ModeData),
   ModeData->InternalModeIndex,
   ModeData->HorizontalResolution,
   ModeData->VerticalResolution,
-  ModeData->ColorDepth,
-  ModeData->RefreshRate
+  ModeData->ColorDepth
   ));
 
 ModeData ++ ;
 VideoMode ++;
   }
@@ -328,19 +326,17 @@ QemuVideoBochsModeSetup (
 if (RequiredFbSize <= AvailableFbSize) {
   ModeData->InternalModeIndex= Index;
   ModeData->HorizontalResolution = VideoMode->Width;
   ModeData->VerticalResolution   = VideoMode->Height;
   ModeData->ColorDepth   = VideoMode->ColorDepth;
-  ModeData->RefreshRate  = 60;
   DEBUG ((EFI_D_INFO,
-"Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
+"Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit\n",
 (INT32) (ModeData - Private->ModeData),
 ModeData->InternalModeIndex,
 ModeData->HorizontalResolution,
 ModeData->VerticalResolution,
-ModeData->ColorDepth,
-ModeData->RefreshRate
+ModeData->ColorDepth
 ));
 
   ModeData ++ ;
 }
 VideoMode ++;
-- 
2.9.2


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 3/5] OvmfPkg/QemuVideoDxe: remove useless QEMU_VIDEO_PRIVATE_DATA.CurrentMode

2016-10-12 Thread Laszlo Ersek
This field is never used.

Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---
 OvmfPkg/QemuVideoDxe/Qemu.h | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h
index 1246b74d4955..f3358d8a7ce0 100644
--- a/OvmfPkg/QemuVideoDxe/Qemu.h
+++ b/OvmfPkg/QemuVideoDxe/Qemu.h
@@ -108,15 +108,13 @@ typedef struct {
   UINT64OriginalPciAttributes;
   EFI_GRAPHICS_OUTPUT_PROTOCOL  GraphicsOutput;
   EFI_DEVICE_PATH_PROTOCOL  *GopDevicePath;
 
   //
-  // The next three fields match the client-visible
-  // EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.Mode and
-  // EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode fields.
+  // The next two fields match the client-visible
+  // EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode field.
   //
-  UINTN CurrentMode;
   UINTN MaxMode;
   QEMU_VIDEO_MODE_DATA  *ModeData;
 
   UINT8 *LineBuffer;
   QEMU_VIDEO_VARIANTVariant;
-- 
2.9.2


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 2/5] OvmfPkg/QemuVideoDxe: drop QEMU_VIDEO_CIRRUS_MODES.RefreshRate

2016-10-12 Thread Laszlo Ersek
Thanks to the previous patch, this field is also unnecessary now. Remove
it.

The patch is best reviewed with "git show --word-diff".

Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---
 OvmfPkg/QemuVideoDxe/Qemu.h   |  1 -
 OvmfPkg/QemuVideoDxe/Initialize.c | 16 
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h
index 7c1f80c772e3..1246b74d4955 100644
--- a/OvmfPkg/QemuVideoDxe/Qemu.h
+++ b/OvmfPkg/QemuVideoDxe/Qemu.h
@@ -129,11 +129,10 @@ typedef struct {
 ///
 typedef struct {
   UINT32  Width;
   UINT32  Height;
   UINT32  ColorDepth;
-  UINT32  RefreshRate;
   UINT8   *CrtcSettings;
   UINT16  *SeqSettings;
   UINT8   MiscSetting;
 } QEMU_VIDEO_CIRRUS_MODES;
 
diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c 
b/OvmfPkg/QemuVideoDxe/Initialize.c
index b12253ba5892..de74fd65ec67 100644
--- a/OvmfPkg/QemuVideoDxe/Initialize.c
+++ b/OvmfPkg/QemuVideoDxe/Initialize.c
@@ -142,18 +142,18 @@ UINT16 Seq_1024_768_32bpp_60[15] = {
 
 ///
 /// Table of supported video modes
 ///
 QEMU_VIDEO_CIRRUS_MODES  QemuVideoCirrusModes[] = {
-//  {  640, 480, 8, 60, Crtc_640_480_256_60,  Seq_640_480_256_60,  0xe3 },
-//  {  800, 600, 8, 60, Crtc_800_600_256_60,  Seq_800_600_256_60,  0xef },
-  {  640, 480, 32, 60, Crtc_640_480_32bpp_60,  Seq_640_480_32bpp_60,  0xef },
-  {  800, 600, 32, 60, Crtc_800_600_32bpp_60,  Seq_800_600_32bpp_60,  0xef },
-//  { 1024, 768, 8, 60, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef }
-  { 1024, 768, 24, 60, Crtc_1024_768_24bpp_60, Seq_1024_768_24bpp_60, 0xef }
-//  { 1024, 768, 32, 60, Crtc_1024_768_32bpp_60, Seq_1024_768_32bpp_60, 0xef }
-//  { 960, 720, 32, 60, Crtc_960_720_32bpp_60, Seq_1024_768_32bpp_60, 0xef }
+//  {  640, 480, 8, Crtc_640_480_256_60,  Seq_640_480_256_60,  0xe3 },
+//  {  800, 600, 8, Crtc_800_600_256_60,  Seq_800_600_256_60,  0xef },
+  {  640, 480, 32, Crtc_640_480_32bpp_60,  Seq_640_480_32bpp_60,  0xef },
+  {  800, 600, 32, Crtc_800_600_32bpp_60,  Seq_800_600_32bpp_60,  0xef },
+//  { 1024, 768, 8, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef }
+  { 1024, 768, 24, Crtc_1024_768_24bpp_60, Seq_1024_768_24bpp_60, 0xef }
+//  { 1024, 768, 32, Crtc_1024_768_32bpp_60, Seq_1024_768_32bpp_60, 0xef }
+//  { 960, 720, 32, Crtc_960_720_32bpp_60, Seq_1024_768_32bpp_60, 0xef }
 };
 
 #define QEMU_VIDEO_CIRRUS_MODE_COUNT \
   (sizeof (QemuVideoCirrusModes) / sizeof (QemuVideoCirrusModes[0]))
 
-- 
2.9.2


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 4/5] OvmfPkg/QemuVideoDxe: remove useless QEMU_VIDEO_PRIVATE_DATA.LineBuffer

2016-10-12 Thread Laszlo Ersek
This field is (re)allocated in QemuVideoGraphicsOutputSetMode(), released
in QemuVideoGraphicsOutputDestructor(), and used for nothing else. Remove
it.

Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---
 OvmfPkg/QemuVideoDxe/Qemu.h |  1 -
 OvmfPkg/QemuVideoDxe/Gop.c  | 16 
 2 files changed, 17 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h
index f3358d8a7ce0..2ce37defc5b8 100644
--- a/OvmfPkg/QemuVideoDxe/Qemu.h
+++ b/OvmfPkg/QemuVideoDxe/Qemu.h
@@ -114,11 +114,10 @@ typedef struct {
   // EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode field.
   //
   UINTN MaxMode;
   QEMU_VIDEO_MODE_DATA  *ModeData;
 
-  UINT8 *LineBuffer;
   QEMU_VIDEO_VARIANTVariant;
   FRAME_BUFFER_CONFIGURE*FrameBufferBltConfigure;
   UINTN FrameBufferBltConfigureSize;
 } QEMU_VIDEO_PRIVATE_DATA;
 
diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
index 532f20e6446c..5485ba3c2871 100644
--- a/OvmfPkg/QemuVideoDxe/Gop.c
+++ b/OvmfPkg/QemuVideoDxe/Gop.c
@@ -165,19 +165,10 @@ Routine Description:
 return EFI_UNSUPPORTED;
   }
 
   ModeData = &Private->ModeData[ModeNumber];
 
-  if (Private->LineBuffer) {
-gBS->FreePool (Private->LineBuffer);
-  }
-
-  Private->LineBuffer = AllocatePool (4 * ModeData->HorizontalResolution);
-  if (Private->LineBuffer == NULL) {
-return EFI_OUT_OF_RESOURCES;
-  }
-
   switch (Private->Variant) {
   case QEMU_VIDEO_CIRRUS_5430:
   case QEMU_VIDEO_CIRRUS_5446:
 InitializeCirrusGraphicsMode (Private, 
&QemuVideoCirrusModes[ModeData->InternalModeIndex]);
 break;
@@ -185,12 +176,10 @@ Routine Description:
   case QEMU_VIDEO_BOCHS:
 InitializeBochsGraphicsMode (Private, 
&QemuVideoBochsModes[ModeData->InternalModeIndex]);
 break;
   default:
 ASSERT (FALSE);
-gBS->FreePool (Private->LineBuffer);
-Private->LineBuffer = NULL;
 return EFI_DEVICE_ERROR;
   }
 
   This->Mode->Mode = ModeNumber;
   This->Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
@@ -347,11 +336,10 @@ QemuVideoGraphicsOutputConstructor (
   if (EFI_ERROR (Status)) {
 goto FreeMode;
   }
   Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode;
   Private->GraphicsOutput.Mode->Mode= GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
-  Private->LineBuffer   = NULL;
   Private->FrameBufferBltConfigure  = NULL;
   Private->FrameBufferBltConfigureSize  = 0;
 
   //
   // Initialize the hardware
@@ -393,14 +381,10 @@ Returns:
 
   None
 
 --*/
 {
-  if (Private->LineBuffer != NULL) {
-FreePool (Private->LineBuffer);
-  }
-
   if (Private->FrameBufferBltConfigure != NULL) {
 FreePool (Private->FrameBufferBltConfigure);
   }
 
   if (Private->GraphicsOutput.Mode != NULL) {
-- 
2.9.2


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 5/5] OvmfPkg/QemuVideoDxe: upgrade VERBOSE debug messages to INFO

2016-10-12 Thread Laszlo Ersek
In commit 5b2291f9567a ("OvmfPkg: QemuVideoDxe uses
MdeModulePkg/FrameBufferLib"), QemuVideoDxe was rebased to
FrameBufferBltLib.

The FrameBufferBltLib instance added in commit b1ca386074bd
("MdeModulePkg: Add FrameBufferBltLib library instance") logs many
messages on the VERBOSE level; for example, a normal boot with OVMF can
produce 500+ "VideoFill" messages, dependent on the progress bar, when the
VERBOSE bit is set in PcdDebugPrintErrorLevel. While FrameBufferBltLib is
certainly allowed to log such messages on the VERBOSE level, we should
separate those frequent messages from the (infrequent) ones produced by
QemuVideoDxe itself.

QemuVideoDxe logs VERBOSE messages in three locations (in two functions)
at the moment. All of them are infrequent: both QemuVideoBochsModeSetup()
and InstallVbeShim() are called from QemuVideoControllerDriverStart(),
that is, when a device is bound. Upgrade these messages to INFO level, so
that VERBOSE can be disabled in PcdDebugPrintErrorLevel -- perhaps
selectively for OvmfPkg/QemuVideoDxe -- without hiding these infrequent
messages.

Cc: Jordan Justen 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---
 OvmfPkg/QemuVideoDxe/Initialize.c | 2 +-
 OvmfPkg/QemuVideoDxe/VbeShim.c| 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c 
b/OvmfPkg/QemuVideoDxe/Initialize.c
index de74fd65ec67..98ca4f8488fe 100644
--- a/OvmfPkg/QemuVideoDxe/Initialize.c
+++ b/OvmfPkg/QemuVideoDxe/Initialize.c
@@ -301,11 +301,11 @@ QemuVideoBochsModeSetup (
 }
   } else {
 AvailableFbSize  = BochsRead (Private, VBE_DISPI_INDEX_VIDEO_MEMORY_64K);
 AvailableFbSize *= SIZE_64KB;
   }
-  DEBUG ((EFI_D_VERBOSE, "%a: AvailableFbSize=0x%x\n", __FUNCTION__,
+  DEBUG ((EFI_D_INFO, "%a: AvailableFbSize=0x%x\n", __FUNCTION__,
 AvailableFbSize));
 
   //
   // Setup Video Modes
   //
diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.c b/OvmfPkg/QemuVideoDxe/VbeShim.c
index 6a569f627449..4c4517e9da27 100644
--- a/OvmfPkg/QemuVideoDxe/VbeShim.c
+++ b/OvmfPkg/QemuVideoDxe/VbeShim.c
@@ -98,20 +98,20 @@ InstallVbeShim (
 // shouldn't override a real video BIOS with our shim, nor our own shim if
 // it's already present.
 //
 Handler = (Int0x10->Segment << 4) + Int0x10->Offset;
 if (Handler >= SegmentC && Handler < SegmentF) {
-  DEBUG ((EFI_D_VERBOSE, "%a: Video BIOS handler found at %04x:%04x\n",
+  DEBUG ((EFI_D_INFO, "%a: Video BIOS handler found at %04x:%04x\n",
 __FUNCTION__, Int0x10->Segment, Int0x10->Offset));
   return;
 }
 
 //
 // Otherwise we'll overwrite the Int10h vector, even though we may not own
 // the page at zero.
 //
-DEBUG ((EFI_D_VERBOSE, "%a: failed to allocate page at zero: %r\n",
+DEBUG ((EFI_D_INFO, "%a: failed to allocate page at zero: %r\n",
   __FUNCTION__, Status));
   } else {
 //
 // We managed to allocate the page at zero. SVN r14218 guarantees that it
 // is NUL-filled.
-- 
2.9.2

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdeModulePkg/MdeModulePkg.dec: Fix EBC build failure of PciBus driver

2016-10-12 Thread Tian, Feng
Seems nobody objects this path.

reviewed-by: Feng Tian 

Thanks
Feng

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ard 
Biesheuvel
Sent: Wednesday, October 12, 2016 4:36 PM
To: Laszlo Ersek 
Cc: Ni, Ruiyu ; edk2-devel@lists.01.org 

Subject: Re: [edk2] [PATCH] MdeModulePkg/MdeModulePkg.dec: Fix EBC build 
failure of PciBus driver

On 12 October 2016 at 08:08, Laszlo Ersek  wrote:
> On 10/12/16 04:36, Ni, Ruiyu wrote:
>> I agree with Ard. Building PciBusDxe driver as EBC ARCH is supported 
>> from tool perspective, but doesn't make much sense in real world.
>> So the patch is just to resolve the build failure in EBC ARCH.
>
> If Ard is fine with the EBC default for 
> PcdPciDegradeResourceForOptionRom that this patch results in, then I 
> don't object.
>
> Acked-by: Laszlo Ersek 
>

Yes, I am fine with that, as long as the default remains FALSE for AARCH64

Acked-by: Ard Biesheuvel  
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 2/2] ArmPlatformPkg/ArmJunoPkg/Drivers/PciHostBridgeDxe: Fix for PCI Dual Address Cycle

2016-10-12 Thread Ard Biesheuvel
On 12 October 2016 at 09:37, Ryan Harkin  wrote:
> On 23 September 2016 at 08:58, Ard Biesheuvel  
> wrote:
>> On 22 September 2016 at 23:33, Daniil Egranov  wrote:
>>> The fix handles the PCI Dual Address Cycle Attribute case. It allows
>>> drivers using PCI DAC run on Juno.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Daniil Egranov 
>>
>> Reviewed-by: Ard Biesheuvel 
>>
>
> Tested on Juno R0/1/2, where R0 doesn't use the Marvell ethernet
> controller, but the SMC ethernet still works.
>
> Tested-by: Ryan Harkin 
>

Pushed, thanks.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 2/2] ArmPlatformPkg/ArmJunoPkg/Drivers/PciHostBridgeDxe: Fix for PCI Dual Address Cycle

2016-10-12 Thread Ryan Harkin
On 23 September 2016 at 08:58, Ard Biesheuvel  wrote:
> On 22 September 2016 at 23:33, Daniil Egranov  wrote:
>> The fix handles the PCI Dual Address Cycle Attribute case. It allows
>> drivers using PCI DAC run on Juno.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Daniil Egranov 
>
> Reviewed-by: Ard Biesheuvel 
>

Tested on Juno R0/1/2, where R0 doesn't use the Marvell ethernet
controller, but the SMC ethernet still works.

Tested-by: Ryan Harkin 

>> ---
>>  .../ArmJunoPkg/Drivers/PciHostBridgeDxe/PciRootBridge.c  | 9 
>> ++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git 
>> a/ArmPlatformPkg/ArmJunoPkg/Drivers/PciHostBridgeDxe/PciRootBridge.c 
>> b/ArmPlatformPkg/ArmJunoPkg/Drivers/PciHostBridgeDxe/PciRootBridge.c
>> index 10a4575..72d0915 100644
>> --- a/ArmPlatformPkg/ArmJunoPkg/Drivers/PciHostBridgeDxe/PciRootBridge.c
>> +++ b/ArmPlatformPkg/ArmJunoPkg/Drivers/PciHostBridgeDxe/PciRootBridge.c
>> @@ -518,11 +518,14 @@ PciRbMap (
>>
>>PCI_TRACE ("PciRbMap()");
>>
>> -  if (Operation == EfiPciOperationBusMasterRead) {
>> +  if (Operation == EfiPciOperationBusMasterRead ||
>> +  Operation == EfiPciOperationBusMasterRead64) {
>>  DmaOperation = MapOperationBusMasterRead;
>> -  } else if (Operation == EfiPciOperationBusMasterWrite) {
>> +  } else if (Operation == EfiPciOperationBusMasterWrite ||
>> + Operation == EfiPciOperationBusMasterWrite64) {
>>  DmaOperation = MapOperationBusMasterWrite;
>> -  } else if (Operation == EfiPciOperationBusMasterCommonBuffer) {
>> +  } else if (Operation == EfiPciOperationBusMasterCommonBuffer ||
>> + Operation == EfiPciOperationBusMasterCommonBuffer64) {
>>  DmaOperation = MapOperationBusMasterCommonBuffer;
>>} else {
>>  return EFI_INVALID_PARAMETER;
>> --
>> 2.7.4
>>
>> ___
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] MdeModulePkg/MdeModulePkg.dec: Fix EBC build failure of PciBus driver

2016-10-12 Thread Ard Biesheuvel
On 12 October 2016 at 08:08, Laszlo Ersek  wrote:
> On 10/12/16 04:36, Ni, Ruiyu wrote:
>> I agree with Ard. Building PciBusDxe driver as EBC ARCH is supported from 
>> tool perspective, but doesn't
>> make much sense in real world.
>> So the patch is just to resolve the build failure in EBC ARCH.
>
> If Ard is fine with the EBC default for
> PcdPciDegradeResourceForOptionRom that this patch results in, then I
> don't object.
>
> Acked-by: Laszlo Ersek 
>

Yes, I am fine with that, as long as the default remains FALSE for AARCH64

Acked-by: Ard Biesheuvel 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


  1   2   >