TianoCore EDK2 master
|
Go to the source code of this file.
Functions | |
RETURN_STATUS EFIAPI | SafeInt32ToUintn (IN INT32 Operand, OUT UINTN *Result) |
RETURN_STATUS EFIAPI | SafeUint32ToIntn (IN UINT32 Operand, OUT INTN *Result) |
RETURN_STATUS EFIAPI | SafeIntnToInt32 (IN INTN Operand, OUT INT32 *Result) |
RETURN_STATUS EFIAPI | SafeIntnToUint32 (IN INTN Operand, OUT UINT32 *Result) |
RETURN_STATUS EFIAPI | SafeUintnToUint32 (IN UINTN Operand, OUT UINT32 *Result) |
RETURN_STATUS EFIAPI | SafeUintnToInt64 (IN UINTN Operand, OUT INT64 *Result) |
RETURN_STATUS EFIAPI | SafeInt64ToIntn (IN INT64 Operand, OUT INTN *Result) |
RETURN_STATUS EFIAPI | SafeInt64ToUintn (IN INT64 Operand, OUT UINTN *Result) |
RETURN_STATUS EFIAPI | SafeUint64ToUintn (IN UINT64 Operand, OUT UINTN *Result) |
RETURN_STATUS EFIAPI | SafeUintnAdd (IN UINTN Augend, IN UINTN Addend, OUT UINTN *Result) |
RETURN_STATUS EFIAPI | SafeUintnSub (IN UINTN Minuend, IN UINTN Subtrahend, OUT UINTN *Result) |
RETURN_STATUS EFIAPI | SafeUintnMult (IN UINTN Multiplicand, IN UINTN Multiplier, OUT UINTN *Result) |
RETURN_STATUS EFIAPI | SafeIntnAdd (IN INTN Augend, IN INTN Addend, OUT INTN *Result) |
RETURN_STATUS EFIAPI | SafeIntnSub (IN INTN Minuend, IN INTN Subtrahend, OUT INTN *Result) |
RETURN_STATUS EFIAPI | SafeIntnMult (IN INTN Multiplicand, IN INTN Multiplier, OUT INTN *Result) |
This library provides helper functions to prevent integer overflow during type conversion, addition, subtraction, and multiplication.
Copyright (c) 2017, Microsoft Corporation
All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file SafeIntLib64.c.
INT32 -> UINTN conversion
Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Operand | Operand to be converted to new type |
[out] | Result | Pointer to the result of conversion |
RETURN_SUCCESS | Successful conversion |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 37 of file SafeIntLib64.c.
INT64 -> INTN conversion
Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the conversion results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Operand | Operand to be converted to new type |
[out] | Result | Pointer to the result of conversion |
RETURN_SUCCESS | Successful conversion |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 222 of file SafeIntLib64.c.
INT64 -> UINTN conversion
Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Operand | Operand to be converted to new type |
[out] | Result | Pointer to the result of conversion |
RETURN_SUCCESS | Successful conversion |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 257 of file SafeIntLib64.c.
INTN Addition
Performs the requested operation using the input parameters into a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the requested operation results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Augend | A number to which addend will be added |
[in] | Addend | A number to be added to another |
[out] | Result | Pointer to the result of addition |
RETURN_SUCCESS | Successful addition |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 419 of file SafeIntLib64.c.
INTN multiplication
Performs the requested operation using the input parameters into a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the requested operation results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Multiplicand | A number that is to be multiplied by another |
[in] | Multiplier | A number by which the multiplicand is to be multiplied |
[out] | Result | Pointer to the result of multiplication |
RETURN_SUCCESS | Successful multiplication |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 483 of file SafeIntLib64.c.
INTN Subtraction
Performs the requested operation using the input parameters into a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the requested operation results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Minuend | A number from which another is to be subtracted. |
[in] | Subtrahend | A number to be subtracted from another |
[out] | Result | Pointer to the result of subtraction |
RETURN_SUCCESS | Successful subtraction |
RETURN_BUFFER_TOO_SMALL | Underflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 451 of file SafeIntLib64.c.
INTN -> INT32 conversion
Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the conversion results in an overflow or an underflow condition, then Result is set to INT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Operand | Operand to be converted to new type |
[out] | Result | Pointer to the result of conversion |
RETURN_SUCCESS | Successful conversion |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 102 of file SafeIntLib64.c.
INTN -> UINT32 conversion
Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Operand | Operand to be converted to new type |
[out] | Result | Pointer to the result of conversion |
RETURN_SUCCESS | Successful conversion |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 132 of file SafeIntLib64.c.
UINT32 -> INTN conversion
Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the conversion results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Operand | Operand to be converted to new type |
[out] | Result | Pointer to the result of conversion |
RETURN_SUCCESS | Successful conversion |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 67 of file SafeIntLib64.c.
UINT64 -> UINTN conversion
Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Operand | Operand to be converted to new type |
[out] | Result | Pointer to the result of conversion |
RETURN_SUCCESS | Successful conversion |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 287 of file SafeIntLib64.c.
UINTN addition
Performs the requested operation using the input parameters into a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the requested operation results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Augend | A number to which addend will be added |
[in] | Addend | A number to be added to another |
[out] | Result | Pointer to the result of addition |
RETURN_SUCCESS | Successful addition |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 323 of file SafeIntLib64.c.
RETURN_STATUS EFIAPI SafeUintnMult | ( | IN UINTN | Multiplicand, |
IN UINTN | Multiplier, | ||
OUT UINTN * | Result | ||
) |
UINTN multiplication
Performs the requested operation using the input parameters into a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the requested operation results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Multiplicand | A number that is to be multiplied by another |
[in] | Multiplier | A number by which the multiplicand is to be multiplied |
[out] | Result | Pointer to the result of multiplication |
RETURN_SUCCESS | Successful multiplication |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 387 of file SafeIntLib64.c.
UINTN subtraction
Performs the requested operation using the input parameters into a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the requested operation results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Minuend | A number from which another is to be subtracted. |
[in] | Subtrahend | A number to be subtracted from another |
[out] | Result | Pointer to the result of subtraction |
RETURN_SUCCESS | Successful subtraction |
RETURN_BUFFER_TOO_SMALL | Underflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 355 of file SafeIntLib64.c.
UINTN -> INT64 conversion
Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the conversion results in an overflow or an underflow condition, then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Operand | Operand to be converted to new type |
[out] | Result | Pointer to the result of conversion |
RETURN_SUCCESS | Successful conversion |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 192 of file SafeIntLib64.c.
UINTN -> UINT32 conversion
Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type.
If Result is NULL, RETURN_INVALID_PARAMETER is returned.
If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
[in] | Operand | Operand to be converted to new type |
[out] | Result | Pointer to the result of conversion |
RETURN_SUCCESS | Successful conversion |
RETURN_BUFFER_TOO_SMALL | Overflow |
RETURN_INVALID_PARAMETER | Result is NULL |
Definition at line 162 of file SafeIntLib64.c.