]> git.proxmox.com Git - mirror_edk2.git/commit
MdeModulePkg/PrintLib: Avoid reading content beyond the format string
authorHao Wu <hao.a.wu@intel.com>
Mon, 22 May 2017 07:03:24 +0000 (15:03 +0800)
committerHao Wu <hao.a.wu@intel.com>
Thu, 1 Jun 2017 00:46:40 +0000 (08:46 +0800)
commit213da0b540891ba614753673ce3ed54940434497
tree5e5e5229efd8704123421b29abe277ad73548776
parentb1d4b9651e1143245eccd99af0e2940635c2058f
MdeModulePkg/PrintLib: Avoid reading content beyond the format string

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

In functions DxePrintLibPrint2ProtocolVaListToBaseList() and
InternalPrintLibSPrintMarker(), 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>
MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c