mirror of https://github.com/acidanthera/audk.git
MdePkg/BaseMemoryLib*: check for zero length in ZeroMem ()
Unlike other string functions in this library, ZeroMem () does not return early when the length of the input buffer is 0. So add the same to ZeroMem () as well, for all implementations of BaseMemoryLib living under MdePkg/ This fixes an issue with the ARM implementation of BaseMemoryLibOPtDxe, whose InternalMemZeroMem code does not expect a length of 0, and always writes at least a single byte. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
669b6cc60b
commit
12a37b2ae1
|
@ -46,7 +46,11 @@ ZeroMem (
|
||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (!(Buffer == NULL && Length > 0));
|
if (Length == 0) {
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
return InternalMemZeroMem (Buffer, Length);
|
return InternalMemZeroMem (Buffer, Length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,11 @@ ZeroMem (
|
||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (!(Buffer == NULL && Length > 0));
|
if (Length == 0) {
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
return InternalMemZeroMem (Buffer, Length);
|
return InternalMemZeroMem (Buffer, Length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,11 @@ ZeroMem (
|
||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (!(Buffer == NULL && Length > 0));
|
if (Length == 0) {
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
return InternalMemZeroMem (Buffer, Length);
|
return InternalMemZeroMem (Buffer, Length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,11 @@ ZeroMem (
|
||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (!(Buffer == NULL && Length > 0));
|
if (Length == 0) {
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
return InternalMemZeroMem (Buffer, Length);
|
return InternalMemZeroMem (Buffer, Length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,11 @@ ZeroMem (
|
||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (!(Buffer == NULL && Length > 0));
|
if (Length == 0) {
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
return InternalMemZeroMem (Buffer, Length);
|
return InternalMemZeroMem (Buffer, Length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,11 @@ ZeroMem (
|
||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (!(Buffer == NULL && Length > 0));
|
if (Length == 0) {
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
return InternalMemZeroMem (Buffer, Length);
|
return InternalMemZeroMem (Buffer, Length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,11 @@ ZeroMem (
|
||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (!(Buffer == NULL && Length > 0));
|
if (Length == 0) {
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
return InternalMemZeroMem (Buffer, Length);
|
return InternalMemZeroMem (Buffer, Length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,11 @@ ZeroMem (
|
||||||
IN UINTN Length
|
IN UINTN Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ASSERT (!(Buffer == NULL && Length > 0));
|
if (Length == 0) {
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
return InternalMemZeroMem (Buffer, Length);
|
return InternalMemZeroMem (Buffer, Length);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue