Add some XString length test.

This commit is contained in:
jief666 2020-08-16 09:01:08 +03:00
parent f6903b7579
commit 3a742b5dbc
3 changed files with 7 additions and 11 deletions

View File

@ -2613,7 +2613,7 @@ GetEarlyUserSettings (
gSettings.KernelScan = KERNEL_SCAN_NONE;
} else if ((Dict2->type == kTagTypeString) && Dict2->string.notEmpty() ) {
if ((Dict2->string[0] == 'N') || (Dict2->string[0] == 'n')) {
gSettings.KernelScan = ((Dict2->string[1] == 'E') || (Dict2->string[1] == 'e')) ? KERNEL_SCAN_NEWEST : KERNEL_SCAN_NONE;
gSettings.KernelScan = ( Dict2->string.length() > 1 && (Dict2->string[1] == 'E' || Dict2->string[1] == 'e') ) ? KERNEL_SCAN_NEWEST : KERNEL_SCAN_NONE;
} else if ((Dict2->string[0] == 'O') || (Dict2->string[0] == 'o')) {
gSettings.KernelScan = KERNEL_SCAN_OLDEST;
} else if ((Dict2->string[0] == 'F') || (Dict2->string[0] == 'f')) {
@ -4830,11 +4830,12 @@ GetUserSettings(
gSettings.HDALayoutId = (INT32)Prop->intValue; //must be signed
gSettings.HDAInjection = (gSettings.HDALayoutId > 0);
} else if (Prop->type == kTagTypeString){
if ((Prop->string[0] == 'n') || (Prop->string[0] == 'N')) {
if ( Prop->string.length() > 0 && (Prop->string[0] == 'n' || Prop->string[0] == 'N') ) {
// if starts with n or N, then no HDA injection
gSettings.HDAInjection = FALSE;
} else if ((Prop->string[0] == '0') &&
(Prop->string[1] == 'x' || Prop->string[1] == 'X')) {
} else if ( Prop->string.length() > 1 &&
Prop->string[0] == '0' &&
( Prop->string[1] == 'x' || Prop->string[1] == 'X' ) ) {
// assume it's a hex layout id
gSettings.HDALayoutId = (INT32)AsciiStrHexToUintn(Prop->string);
gSettings.HDAInjection = TRUE;

View File

@ -1022,7 +1022,7 @@ GetPropertyInteger(
if (Prop->type == kTagTypeInteger) {
return Prop->intValue; //this is union char* or size_t
} else if ((Prop->type == kTagTypeString) && Prop->string.notEmpty()) {
if ( Prop->string.length() > 2 && (Prop->string[1] == 'x' || Prop->string[1] == 'X') ) {
if ( Prop->string.length() > 1 && (Prop->string[1] == 'x' || Prop->string[1] == 'X') ) {
return (INTN)AsciiStrHexToUintn(Prop->string);
}

View File

@ -961,12 +961,7 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume)
FreePool(RootInfo);
}
}
if (
Volume->VolName.isEmpty()
|| Volume->VolName[0] == 0
|| (Volume->VolName[0] == L'\\' && Volume->VolName[1] == 0)
|| (Volume->VolName[0] == L'/' && Volume->VolName[1] == 0)
)
if ( Volume->VolName.isEmpty() || Volume->VolName.equal("\\") || Volume->VolName.equal(L"/") )
{
VOID *Instance;
if (!EFI_ERROR(gBS->HandleProtocol(Volume->DeviceHandle, &gEfiPartTypeSystemPartGuid, &Instance))) {