Skip to content

Commit

Permalink
Make CopyMem() work with EFI's declaration.
Browse files Browse the repository at this point in the history
EFI_BOOT_SERVICES includes CopyMem() and SetMem() functions which are
marked EFIAPI, and in the case of CopyMem() does not mark the source
argument as CONST.

This patch makes all our invocations work with that, so (once gnu-efi's
implementation is fixed to match) we can use the existing implementation
as the implementation in a mock EFI_BOOT_SERVICES.

Signed-off-by: Peter Jones <pjones@redhat.com>
  • Loading branch information
vathpela committed Aug 17, 2021
1 parent 1b30c2b commit 9f9fb29
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cryptlib/Hash/CryptMd5.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Md5Duplicate (
return FALSE;
}

CopyMem (NewMd5Context, Md5Context, sizeof (MD5_CTX));
CopyMem (NewMd5Context, (void *)Md5Context, sizeof (MD5_CTX));

return TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion Cryptlib/Hash/CryptSha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Sha1Duplicate (
return FALSE;
}

CopyMem (NewSha1Context, Sha1Context, sizeof (SHA_CTX));
CopyMem (NewSha1Context, (void *)Sha1Context, sizeof (SHA_CTX));

return TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion Cryptlib/Hash/CryptSha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Sha256Duplicate (
return FALSE;
}

CopyMem (NewSha256Context, Sha256Context, sizeof (SHA256_CTX));
CopyMem (NewSha256Context, (void *)Sha256Context, sizeof (SHA256_CTX));

return TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions Cryptlib/Hash/CryptSha512.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Sha384Duplicate (
return FALSE;
}

CopyMem (NewSha384Context, Sha384Context, sizeof (SHA512_CTX));
CopyMem (NewSha384Context, (void *)Sha384Context, sizeof (SHA512_CTX));

return TRUE;
}
Expand Down Expand Up @@ -308,7 +308,7 @@ Sha512Duplicate (
return FALSE;
}

CopyMem (NewSha512Context, Sha512Context, sizeof (SHA512_CTX));
CopyMem (NewSha512Context, (void *)Sha512Context, sizeof (SHA512_CTX));

return TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions Cryptlib/Include/OpenSslSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ extern FILE *stdout;
//
// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
//
#define memcpy(dest,source,count) ( {CopyMem(dest,source,(UINTN)(count)); dest; })
#define memcpy(dest,source,count) ( {CopyMem(dest,(void *)source,(UINTN)(count)); dest; })
#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
#define memchr(buf,ch,count) ScanMem8((CHAR8 *)buf,(UINTN)(count),ch)
#define memcmp(buf1,buf2,count) (int)(CompareMem(buf1,buf2,(UINTN)(count)))
#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count))
#define memmove(dest,source,count) CopyMem(dest,(void *)source,(UINTN)(count))
#define localtime(timer) NULL
#define assert(expression)
#define atoi(nptr) AsciiStrDecimalToUintn((const CHAR8 *)nptr)
Expand Down
2 changes: 1 addition & 1 deletion Cryptlib/Pk/CryptPkcs7Verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ WrapPkcs7Data (
//
// Part7: P7Data.
//
CopyMem (SignedData + 19, P7Data, P7Length);
CopyMem (SignedData + 19, (void *)P7Data, P7Length);
}

*WrapFlag = Wrapped;
Expand Down
6 changes: 3 additions & 3 deletions httpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ generate_next_uri (CONST CHAR8 *current_uri, CONST CHAR8 *next_loader,
if (!*uri)
return EFI_OUT_OF_RESOURCES;

CopyMem(*uri, current_uri, path_len);
CopyMem(*uri + path_len, next_loader, next_len);
CopyMem(*uri, (void *)current_uri, path_len);
CopyMem(*uri + path_len, (void *)next_loader, next_len);
(*uri)[path_len + next_len] = '\0';

return EFI_SUCCESS;
Expand Down Expand Up @@ -209,7 +209,7 @@ extract_hostname (CONST CHAR8 *url, CHAR8 **hostname)
if (!*hostname)
return EFI_OUT_OF_RESOURCES;

CopyMem(*hostname, start, host_len);
CopyMem(*hostname, (void *)start, host_len);
(*hostname)[host_len] = '\0';

return EFI_SUCCESS;
Expand Down
6 changes: 3 additions & 3 deletions lib/variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fill_esl(const EFI_SIGNATURE_DATA *first_sig, const size_t howmany,
sl->SignatureListSize = needed;

sd = (EFI_SIGNATURE_DATA *)(out + sizeof(EFI_SIGNATURE_LIST));
CopyMem(sd, first_sig, data_len);
CopyMem(sd, (void *)first_sig, data_len);

return EFI_SUCCESS;
}
Expand All @@ -69,8 +69,8 @@ fill_esl_with_one_signature(const uint8_t *data, const uint32_t data_len,
if (out) {
sd = AllocateZeroPool(sig_size);
if (owner)
CopyMem(sd, owner, sizeof(EFI_GUID));
CopyMem(sd->SignatureData, data, data_len);
CopyMem(sd, (void *)owner, sizeof(EFI_GUID));
CopyMem(sd->SignatureData, (void *)data, data_len);
}

efi_status = fill_esl(sd, 1, type, sig_size, out, outlen);
Expand Down

0 comments on commit 9f9fb29

Please sign in to comment.