audk/MdePkg/Include
Sean Brogan d7a09cb86a MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance
https://bugzilla.tianocore.org/show_bug.cgi?id=798

SafeIntLib provides helper functions to prevent integer overflow
during type conversion, addition, subtraction, and multiplication.

Conversion Functions
====================
* Converting from a signed type to an unsigned type of the same
  size, or vice-versa.
* Converting to a smaller type that could possibly overflow.
* Converting from a signed type to a larger unsigned type.

Unsigned Addition, Subtraction, Multiplication
===============================================
* Unsigned integer math functions protect from overflow and
  underflow (in case of subtraction).

Signed Addition, Subtraction, Multiplication
============================================
* Strongly consider using unsigned numbers.
* Signed numbers are often used where unsigned numbers should
  be used. For example file sizes and array indices should always
  be unsigned. Subtracting a larger positive signed number from a
  smaller positive signed number with SafeInt32Sub() will succeed,
  producing a negative number, that then must not be used as an
  array index (but can occasionally be used as a pointer index.)
  Similarly for adding a larger magnitude negative number to a
  smaller magnitude positive number.
* SafeIntLib does not protect you from such errors. It tells you
  if your integer operations overflowed, not if you are doing the
  right thing with your non-overflowed integers.
* Likewise you can overflow a buffer with a non-overflowed
  unsigned index.

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
21ef3a321c
ca516b1a61
33bab4031a

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-01-25 09:42:20 -08:00
..
AArch64 MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance 2018-01-25 09:42:20 -08:00
Arm MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance 2018-01-25 09:42:20 -08:00
Ebc MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance 2018-01-25 09:42:20 -08:00
Guid MdePkg MemoryOverwriteControl.h: Correct typo 'bi' to 'bit' 2017-12-19 09:34:47 +08:00
Ia32 MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance 2018-01-25 09:42:20 -08:00
IndustryStandard SecurityPkg:Tpm2DeviceLibDTpm: Support TPM command cancel 2018-01-25 22:14:28 +08:00
Ipf MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance 2018-01-25 09:42:20 -08:00
Library MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance 2018-01-25 09:42:20 -08:00
Pi MdePkg/Include/Pi: Modify specification number encoding 2017-12-15 09:24:09 +08:00
Ppi MdePkg: Add definition for SecHobData PPI 2017-08-04 08:56:05 +08:00
Protocol MdePkg PciIo.h: Correct function description for ALLOCATE_BUFFER 2017-12-12 09:31:53 +08:00
Uefi MdePkg/UefiSpec.h: Update the UEFI version to reflect new revision 2017-12-15 09:20:42 +08:00
X64 MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance 2018-01-25 09:42:20 -08:00
Base.h MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance 2018-01-25 09:42:20 -08:00
PiDxe.h
PiMm.h MdePkg: Add new definitions for Management Mode. 2017-08-29 09:37:36 +08:00
PiPei.h
PiSmm.h MdePkg: Follow UEFI 2.7 spec to deprecate SMM Communication ACPI Table 2017-07-27 14:08:09 +08:00
Uefi.h