audk/ShellPkg/Library
Laszlo Ersek bbf57d4fb9 ShellPkg: UefiShellDebug1CommandsLib: fix hex string parsing in SETVAR
The ShellCommandRunSetVar() function calls the ShellIsHexOrDecimalNumber()
UefiShellLib function to determine if the data string in the SETVAR
command is a string of hexadecimal bytes.

However, ShellIsHexOrDecimalNumber() calls ShellConvertStringToUint64()
for validation. Therefore SETVAR rejects hex strings that cannot be
interpreted as UINT64 values due to range errors, despite the fact that
the hexadecimal data string of the SETVAR command is supposed to describe
an arbitrary array of bytes, rather than UINT64 values.

The internal library function InternalShellIsHexOrDecimalNumber() comes
close, as the first idea for the fix, however it is not quite right
either; it removes a leading minus sign, plus it allows 0x / 0X prefixes.
This would not be correct for the SETVAR command.

Instead, add a trivial utility function that is specific to the SETVAR
implementation. IsStringOfHexNibbles() accepts empty strings for
simplicity, but where we call it we have already ensured that the data
string is not empty (because that is handled earlier by the "delete
variable" branch of SETVAR). An even number of nibbles is also enforced
near the call site.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17128 6f19259b-4bc3-4df7-8a09-765794883524
2015-04-07 14:18:40 +00:00
..
UefiDpLib ShellPkg: Help and Error Messages Update 2015-03-09 22:18:59 +00:00
UefiHandleParsingLib ShellPkg: Standardized HP Copyright Message String 2015-02-04 22:25:01 +00:00
UefiShellBcfgCommandLib ShellPkg: Help and Error Messages Update 2015-03-09 22:18:59 +00:00
UefiShellCEntryLib ShellPkg: Refine the fomat in INF/DEC files to follow spec. 2015-01-22 01:44:11 +00:00
UefiShellCommandLib ShellPkg: Standardized HP Copyright Message String 2015-02-04 22:25:01 +00:00
UefiShellDebug1CommandsLib ShellPkg: UefiShellDebug1CommandsLib: fix hex string parsing in SETVAR 2015-04-07 14:18:40 +00:00
UefiShellDriver1CommandsLib ShellPkg: Standardized HP Copyright Message String 2015-02-04 22:25:01 +00:00
UefiShellInstall1CommandsLib ShellPkg: Refine the fomat in INF/DEC files to follow spec. 2015-01-22 01:44:11 +00:00
UefiShellLevel1CommandsLib ShellPkg: Standardized HP Copyright Message String 2015-02-04 22:25:01 +00:00
UefiShellLevel2CommandsLib ShellPkg: Help and Error Messages Update 2015-03-09 22:18:59 +00:00
UefiShellLevel3CommandsLib ShellPkg: Standardized HP Copyright Message String 2015-02-04 22:25:01 +00:00
UefiShellLib ShellPkg: Remove extra quotes surrounding flag values. 2015-04-01 00:49:05 +00:00
UefiShellNetwork1CommandsLib ShellPkg: Fix typo in ShellPkg. 2015-03-17 01:58:10 +00:00