]> git.proxmox.com Git - mirror_edk2.git/commit - MdePkg/Library/BasePrintLib/PrintLibInternal.c
MdePkg/BasePrintLib: Avoid reading content beyond the format string
authorHao Wu <hao.a.wu@intel.com>
Mon, 22 May 2017 06:49:11 +0000 (14:49 +0800)
committerHao Wu <hao.a.wu@intel.com>
Thu, 1 Jun 2017 00:46:31 +0000 (08:46 +0800)
commitb1d4b9651e1143245eccd99af0e2940635c2058f
treef31f9e91bb32aa82582a88a75ed098c5081b3062
parent4fc8277133fb011d028b4e0a42444ab6f552d0b9
MdePkg/BasePrintLib: Avoid reading content beyond the format string

https://bugzilla.tianocore.org/show_bug.cgi?id=567

In function BasePrintLibSPrintMarker(), when processing ASCII format
strings, if the format string walker pointer 'Format' is pointing at the
end of the format string (i.e. '\0'), the following expression:
*(Format + 1)
will read an undefined value.

Though this value won't affect the functionality, since it will be masked
by variable 'FormatMask':
(*(Format + 1) << 8)) & FormatMask
(FormatMask is 0xff for ASCII format string)

This commit adds additional logic to avoid reading undefined content.

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/Library/BasePrintLib/PrintLibInternal.c