mirror of https://github.com/acidanthera/audk.git
Checks the length of the file name to avoid illegal access.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Gary Ching-Pang Lin <glin@suse.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Guo Dong <guo.dong@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14531 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
716e507720
commit
fd64f84f23
|
@ -399,6 +399,7 @@ EnrollPlatformKey (
|
||||||
UINTN DataSize;
|
UINTN DataSize;
|
||||||
EFI_SIGNATURE_LIST *PkCert;
|
EFI_SIGNATURE_LIST *PkCert;
|
||||||
UINT16* FilePostFix;
|
UINT16* FilePostFix;
|
||||||
|
UINTN NameLength;
|
||||||
|
|
||||||
if (Private->FileContext->FileName == NULL) {
|
if (Private->FileContext->FileName == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
@ -414,7 +415,11 @@ EnrollPlatformKey (
|
||||||
//
|
//
|
||||||
// Parse the file's postfix. Only support DER encoded X.509 certificate files.
|
// Parse the file's postfix. Only support DER encoded X.509 certificate files.
|
||||||
//
|
//
|
||||||
FilePostFix = Private->FileContext->FileName + StrLen (Private->FileContext->FileName) - 4;
|
NameLength = StrLen (Private->FileContext->FileName);
|
||||||
|
if (NameLength <= 4) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
FilePostFix = Private->FileContext->FileName + NameLength - 4;
|
||||||
if (!IsDerEncodeCertificate(FilePostFix)) {
|
if (!IsDerEncodeCertificate(FilePostFix)) {
|
||||||
DEBUG ((EFI_D_ERROR, "Unsupported file type, only DER encoded certificate (%s) is supported.", mSupportX509Suffix));
|
DEBUG ((EFI_D_ERROR, "Unsupported file type, only DER encoded certificate (%s) is supported.", mSupportX509Suffix));
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
@ -803,6 +808,7 @@ EnrollKeyExchangeKey (
|
||||||
{
|
{
|
||||||
UINT16* FilePostFix;
|
UINT16* FilePostFix;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
UINTN NameLength;
|
||||||
|
|
||||||
if ((Private->FileContext->FileName == NULL) || (Private->SignatureGUID == NULL)) {
|
if ((Private->FileContext->FileName == NULL) || (Private->SignatureGUID == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
@ -817,7 +823,11 @@ EnrollKeyExchangeKey (
|
||||||
// Parse the file's postfix. Supports DER-encoded X509 certificate,
|
// Parse the file's postfix. Supports DER-encoded X509 certificate,
|
||||||
// and .pbk as RSA public key file.
|
// and .pbk as RSA public key file.
|
||||||
//
|
//
|
||||||
FilePostFix = Private->FileContext->FileName + StrLen (Private->FileContext->FileName) - 4;
|
NameLength = StrLen (Private->FileContext->FileName);
|
||||||
|
if (NameLength <= 4) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
FilePostFix = Private->FileContext->FileName + NameLength - 4;
|
||||||
if (IsDerEncodeCertificate(FilePostFix)) {
|
if (IsDerEncodeCertificate(FilePostFix)) {
|
||||||
return EnrollX509ToKek (Private);
|
return EnrollX509ToKek (Private);
|
||||||
} else if (CompareMem (FilePostFix, L".pbk",4) == 0) {
|
} else if (CompareMem (FilePostFix, L".pbk",4) == 0) {
|
||||||
|
@ -1551,6 +1561,7 @@ EnrollSignatureDatabase (
|
||||||
{
|
{
|
||||||
UINT16* FilePostFix;
|
UINT16* FilePostFix;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
UINTN NameLength;
|
||||||
|
|
||||||
if ((Private->FileContext->FileName == NULL) || (Private->FileContext->FHandle == NULL) || (Private->SignatureGUID == NULL)) {
|
if ((Private->FileContext->FileName == NULL) || (Private->FileContext->FHandle == NULL) || (Private->SignatureGUID == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
@ -1564,7 +1575,11 @@ EnrollSignatureDatabase (
|
||||||
//
|
//
|
||||||
// Parse the file's postfix.
|
// Parse the file's postfix.
|
||||||
//
|
//
|
||||||
FilePostFix = Private->FileContext->FileName + StrLen (Private->FileContext->FileName) - 4;
|
NameLength = StrLen (Private->FileContext->FileName);
|
||||||
|
if (NameLength <= 4) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
FilePostFix = Private->FileContext->FileName + NameLength - 4;
|
||||||
if (IsDerEncodeCertificate(FilePostFix)) {
|
if (IsDerEncodeCertificate(FilePostFix)) {
|
||||||
//
|
//
|
||||||
// Supports DER-encoded X509 certificate.
|
// Supports DER-encoded X509 certificate.
|
||||||
|
|
Loading…
Reference in New Issue