Skip to content
Snippets Groups Projects
Commit 016977ed authored by Peter Jones's avatar Peter Jones Committed by Colin Watson
Browse files

safemath: Add some arithmetic primitives that check for overflow


This adds a new header, include/grub/safemath.h, that includes easy to
use wrappers for __builtin_{add,sub,mul}_overflow() declared like:

  bool OP(a, b, res)

where OP is grub_add, grub_sub or grub_mul. OP() returns true in the
case where the operation would overflow and res is not modified.
Otherwise, false is returned and the operation is executed.

These arithmetic primitives require newer compiler versions. So, bump
these requirements in the INSTALL file too.

Signed-off-by: default avatarPeter Jones <pjones@redhat.com>
Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>

Patch-Name: safe-alloc-1.patch
parent 705b89f1
Loading
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