]> git.proxmox.com Git - mirror_edk2.git/commit - MdePkg/Library/BasePrintLib/PrintLib.c
MdePkg/BasePrintLib: Add safe print functions [A|U]ValueToStringS
authorHao Wu <hao.a.wu@intel.com>
Fri, 23 Dec 2016 06:34:26 +0000 (14:34 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 21 Feb 2017 05:56:14 +0000 (13:56 +0800)
commit51f0ceb4eb47a13845c887758da4fbed4ecbb0cd
tree2d94de3f3f8bf7c207de54d880a16dc563fd83e1
parent0b6642e60eee7456a6075fdb1a011ad4a1d3f31d
MdePkg/BasePrintLib: Add safe print functions [A|U]ValueToStringS

Add the following 2 APIs:
UnicodeValueToStringS
AsciiValueToStringS

These safe version APIs are used to enhance their counterpart (APIs
without trailing 'S' in function names).

They perform checks to the input parameters and will return relative
status to reflect the check result.

Return RETURN_INVALID_PARAMETER when:
1). The input Buffer is NULL.
2). The input BufferSize is greater than (PcdMaximumUnicodeStringLength *
sizeof (CHAR16) + 1) for UnicodeValueToStringS or greater than
PcdMaximumAsciiStringLength for AsciiValueToStringS.
3). The input Flags is not set properly.
4). The input Width is not smaller than MAXIMUM_VALUE_CHARACTERS.

Return RETURN_BUFFER_TOO_SMALL when:
1). The input BufferSize cannot hold the converted value.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Include/Library/PrintLib.h
MdePkg/Library/BasePrintLib/PrintLib.c
MdePkg/Library/BasePrintLib/PrintLibInternal.c
MdePkg/Library/BasePrintLib/PrintLibInternal.h