Skip to content
Snippets Groups Projects
Commit 2f01e9c0 authored by Zhang Boyang's avatar Zhang Boyang Committed by Steve McIntyre
Browse files

font: Fix size overflow in grub_font_get_glyph_internal()


The length of memory allocation and file read may overflow. This patch
fixes the problem by using safemath macros.

There is a lot of code repetition like "(x * y + 7) / 8". It is unsafe
if overflow happens. This patch introduces grub_video_bitmap_calc_1bpp_bufsz().
It is safe replacement for such code. It has safemath-like prototype.

This patch also introduces grub_cast(value, pointer), it casts value to
typeof(*pointer) then store the value to *pointer. It returns true when
overflow occurs or false if there is no overflow. The semantics of arguments
and return value are designed to be consistent with other safemath macros.

Signed-off-by: default avatarZhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
parent 280a9f21
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment