]> git.proxmox.com Git - mirror_edk2.git/commit
MdeModulePkg/HiiDB: Avoid incorrect results of multiplication
authorDandan Bi <dandan.bi@intel.com>
Wed, 12 Apr 2017 03:21:52 +0000 (11:21 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 18 Apr 2017 07:56:22 +0000 (15:56 +0800)
commitf76bc44362e5f0a2ea509c07b2f6846bd9833ee8
tree33276db9754832872ef163db5fff2aba54de792f
parentd508fe87fe73f1e99c5e71ff2aa49459cbe68d2f
MdeModulePkg/HiiDB: Avoid incorrect results of multiplication

An example:
The codes in function Output8bitPixel in Image.c:
OffsetY = BITMAP_LEN_8_BIT ((UINT32) Image->Width, Ypos);

Both Image->Width and Ypos are of type UINT16. They will be promoted to
int (signed) first, and then perform the multiplication defined by macro
BITMAP_LEN_8_BIT. If the result of multiplication between Image->Width and
Ypos exceeds the range of type int, a potential incorrect results
will be assigned to OffsetY.

This commit adds explicit UINT32 type cast for 'Image->Width' to avoid
possible overflow in the int range. And also fix similar issues in
HiiDatabase.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
MdeModulePkg/Universal/HiiDatabaseDxe/Image.c