Changeset 77662 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
- Timestamp:
- Mar 12, 2019 12:40:12 PM (6 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776 /vendor/edk2/current 103735-103757,103769-103776,129194-129237
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/UefiHiiLib/HiiLib.c
r58466 r77662 2 2 HII Library implementation that uses DXE protocols and services. 3 3 4 Copyright (c) 2006 - 201 3, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> 5 5 This program and the accompanying materials 6 6 are licensed and made available under the terms and conditions of the BSD License … … 376 376 } 377 377 } 378 } 379 380 /** 381 This function allows a caller to extract the form set opcode form the Hii Handle. 382 The returned buffer is allocated using AllocatePool().The caller is responsible 383 for freeing the allocated buffer using FreePool(). 384 385 @param Handle The HII handle. 386 @param Buffer On return, points to a pointer which point to the buffer that contain the formset opcode. 387 @param BufferSize On return, points to the length of the buffer. 388 389 @retval EFI_OUT_OF_RESOURCES No enough memory resource is allocated. 390 @retval EFI_NOT_FOUND Can't find the package data for the input Handle. 391 @retval EFI_INVALID_PARAMETER The input parameters are not correct. 392 @retval EFI_SUCCESS Get the formset opcode from the hii handle successfully. 393 394 **/ 395 EFI_STATUS 396 EFIAPI 397 HiiGetFormSetFromHiiHandle( 398 IN EFI_HII_HANDLE Handle, 399 OUT EFI_IFR_FORM_SET **Buffer, 400 OUT UINTN *BufferSize 401 ) 402 { 403 EFI_STATUS Status; 404 UINTN PackageListSize; 405 UINTN TempSize; 406 EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList; 407 UINT8 *Package; 408 UINT8 *OpCodeData; 409 UINT8 *FormSetBuffer; 410 UINT8 *TempBuffer; 411 UINT32 Offset; 412 UINT32 Offset2; 413 UINT32 PackageListLength; 414 EFI_HII_PACKAGE_HEADER PackageHeader; 415 416 TempSize = 0; 417 FormSetBuffer = NULL; 418 TempBuffer = NULL; 419 420 // 421 // Get HII PackageList 422 // 423 PackageListSize = 0; 424 HiiPackageList = NULL; 425 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &PackageListSize, HiiPackageList); 426 if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) { 427 return Status; 428 } 429 430 HiiPackageList = AllocatePool (PackageListSize); 431 if (HiiPackageList == NULL) { 432 return EFI_OUT_OF_RESOURCES; 433 } 434 435 Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &PackageListSize, HiiPackageList); 436 ASSERT_EFI_ERROR (Status); 437 438 // 439 // Get Form package from this HII package List 440 // 441 Status = EFI_NOT_FOUND; 442 Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER); 443 PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength); 444 445 while (Offset < PackageListLength) { 446 Package = ((UINT8 *) HiiPackageList) + Offset; 447 CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER)); 448 Offset += PackageHeader.Length; 449 450 if (PackageHeader.Type != EFI_HII_PACKAGE_FORMS) { 451 continue; 452 } 453 454 // 455 // Search FormSet Opcode in this Form Package 456 // 457 Offset2 = sizeof (EFI_HII_PACKAGE_HEADER); 458 while (Offset2 < PackageHeader.Length) { 459 OpCodeData = Package + Offset2; 460 Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length; 461 462 if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode != EFI_IFR_FORM_SET_OP) { 463 continue; 464 } 465 466 if (FormSetBuffer != NULL){ 467 TempBuffer = ReallocatePool ( 468 TempSize, 469 TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length, 470 FormSetBuffer 471 ); 472 if (TempBuffer == NULL) { 473 Status = EFI_OUT_OF_RESOURCES; 474 goto Done; 475 } 476 CopyMem (TempBuffer + TempSize, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length); 477 FormSetBuffer = NULL; 478 } else { 479 TempBuffer = AllocatePool (TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length); 480 if (TempBuffer == NULL) { 481 Status = EFI_OUT_OF_RESOURCES; 482 goto Done; 483 } 484 CopyMem (TempBuffer, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length); 485 } 486 TempSize += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length; 487 FormSetBuffer = TempBuffer; 488 489 Status = EFI_SUCCESS; 490 // 491 //One form package has one formset, exit current form package to search other form package in the packagelist. 492 // 493 break; 494 } 495 } 496 Done: 497 FreePool (HiiPackageList); 498 499 *BufferSize = TempSize; 500 *Buffer = (EFI_IFR_FORM_SET *)FormSetBuffer; 501 502 return Status; 378 503 } 379 504 … … 576 701 @param[in] Guid Pointer to an EFI_GUID that is the routing information 577 702 GUID. Each of the 16 bytes in Guid is converted to 578 a 2 Unicode character hex idecimal string. This is703 a 2 Unicode character hexadecimal string. This is 579 704 an optional parameter that may be NULL. 580 705 @param[in] Name Pointer to a Null-terminated Unicode string that is … … 582 707 parameter that may be NULL. Each 16-bit Unicode 583 708 character in Name is converted to a 4 character Unicode 584 hex idecimal string.709 hexadecimal string. 585 710 @param[in] DriverHandle The driver handle which supports a Device Path Protocol 586 711 that is the routing information PATH. Each byte of 587 712 the Device Path associated with DriverHandle is converted 588 to a 2 Unicode character hex idecimal string.713 to a 2 Unicode character hexadecimal string. 589 714 590 715 @retval NULL DriverHandle does not support the Device Path Protocol. … … 607 732 UINTN Index; 608 733 UINT8 *Buffer; 734 UINTN MaxLen; 609 735 610 736 // … … 637 763 // | 5 | sizeof (EFI_GUID) * 2 | 6 | NameStrLen*4 | 6 | DevicePathSize * 2 | 1 | 638 764 // 639 String = AllocateZeroPool ((5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16)); 765 MaxLen = 5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathSize * 2 + 1; 766 String = AllocateZeroPool (MaxLen * sizeof (CHAR16)); 640 767 if (String == NULL) { 641 768 return NULL; … … 645 772 // Start with L"GUID=" 646 773 // 647 ReturnString = StrCpy (String, L"GUID="); 774 StrCpyS (String, MaxLen, L"GUID="); 775 ReturnString = String; 648 776 String += StrLen (String); 649 777 … … 653 781 // 654 782 for (Index = 0, Buffer = (UINT8 *)Guid; Index < sizeof (EFI_GUID); Index++) { 655 String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2); 783 UnicodeValueToStringS ( 784 String, 785 MaxLen * sizeof (CHAR16) - ((UINTN)String - (UINTN)ReturnString), 786 PREFIX_ZERO | RADIX_HEX, 787 *(Buffer++), 788 2 789 ); 790 String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16)); 656 791 } 657 792 } … … 660 795 // Append L"&NAME=" 661 796 // 662 StrC py (String, L"&NAME=");797 StrCatS (ReturnString, MaxLen, L"&NAME="); 663 798 String += StrLen (String); 664 799 … … 668 803 // 669 804 for (; *Name != L'\0'; Name++) { 670 String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *Name, 4); 805 UnicodeValueToStringS ( 806 String, 807 sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString), 808 PREFIX_ZERO | RADIX_HEX, 809 *Name, 810 4 811 ); 812 String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16)); 671 813 } 672 814 } … … 675 817 // Append L"&PATH=" 676 818 // 677 StrC py (String, L"&PATH=");819 StrCatS (ReturnString, MaxLen, L"&PATH="); 678 820 String += StrLen (String); 679 821 … … 682 824 // 683 825 for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) { 684 String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2); 826 UnicodeValueToStringS ( 827 String, 828 sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString), 829 PREFIX_ZERO | RADIX_HEX, 830 *(Buffer++), 831 2 832 ); 833 String += StrnLenS (String, MaxLen - ((UINTN)String - (UINTN)ReturnString) / sizeof (CHAR16)); 685 834 } 686 835 … … 787 936 ZeroMem (TemStr, sizeof (TemStr)); 788 937 for (Index = 0; Index < Length; Index += 4) { 789 StrnCpy (TemStr, ConfigHdr + Index, 4);938 StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), ConfigHdr + Index, 4); 790 939 StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr); 791 940 } … … 1007 1156 EFI_IFR_TYPE_VALUE TmpValue; 1008 1157 EFI_STATUS Status; 1009 EFI_HII_PACKAGE_HEADER Pac akgeHeader;1158 EFI_HII_PACKAGE_HEADER PackageHeader; 1010 1159 UINT32 PackageOffset; 1011 1160 UINT8 *PackageData; … … 1025 1174 CHAR16 *QuestionName; 1026 1175 CHAR16 *StringPtr; 1176 UINT16 BitOffset; 1177 UINT16 BitWidth; 1178 UINT16 TotalBits; 1179 UINTN StartBit; 1180 UINTN EndBit; 1181 BOOLEAN QuestionReferBitField; 1182 UINT32 BufferValue; 1027 1183 1028 1184 // … … 1038 1194 ZeroMem (&VarStoreData, sizeof (IFR_VARSTORAGE_DATA)); 1039 1195 ZeroMem (&VarBlockData, sizeof (VarBlockData)); 1196 BitOffset = 0; 1197 BitWidth = 0; 1198 QuestionReferBitField = FALSE; 1040 1199 1041 1200 // … … 1044 1203 PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER); 1045 1204 while (PackageOffset < PackageListLength) { 1046 CopyMem (&Pac akgeHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PacakgeHeader));1205 CopyMem (&PackageHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PackageHeader)); 1047 1206 1048 1207 // 1049 1208 // Parse IFR opcode from the form package. 1050 1209 // 1051 if (Pac akgeHeader.Type == EFI_HII_PACKAGE_FORMS) {1052 IfrOffset = sizeof (Pac akgeHeader);1210 if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) { 1211 IfrOffset = sizeof (PackageHeader); 1053 1212 PackageData = (UINT8 *) HiiPackageList + PackageOffset; 1054 while (IfrOffset < Pac akgeHeader.Length) {1213 while (IfrOffset < PackageHeader.Length) { 1055 1214 IfrOpHdr = (EFI_IFR_OP_HEADER *) (PackageData + IfrOffset); 1056 1215 // … … 1201 1360 // Get Offset by Question header and Width by DataType Flags 1202 1361 // 1203 Offset = IfrOneOf->Question.VarStoreInfo.VarOffset; 1204 Width = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); 1362 if (QuestionReferBitField) { 1363 // 1364 // Get the byte offset/width for bit field. 1365 // 1366 BitOffset = IfrOneOf->Question.VarStoreInfo.VarOffset; 1367 BitWidth = IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT; 1368 Offset = BitOffset / 8; 1369 TotalBits = BitOffset % 8 + BitWidth; 1370 Width = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1); 1371 } else { 1372 Offset = IfrOneOf->Question.VarStoreInfo.VarOffset; 1373 Width = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE)); 1374 } 1205 1375 // 1206 1376 // Check whether this question is in current block array. … … 1226 1396 // 1227 1397 VarValue = 0; 1228 CopyMem (&VarValue, VarBuffer + Offset, Width); 1398 if (QuestionReferBitField) { 1399 // 1400 // Get the value in bit fields. 1401 // 1402 StartBit = BitOffset % 8; 1403 EndBit = StartBit + BitWidth - 1; 1404 CopyMem ((UINT8 *) &BufferValue, VarBuffer + Offset, Width); 1405 VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit); 1406 } else { 1407 CopyMem (&VarValue, VarBuffer + Offset, Width); 1408 } 1229 1409 } 1230 1410 // … … 1272 1452 // Get Offset by Question header and Width by DataType Flags 1273 1453 // 1274 Offset = IfrNumeric->Question.VarStoreInfo.VarOffset; 1275 Width = (UINT16) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); 1454 if (QuestionReferBitField) { 1455 // 1456 // Get the byte offset/width for bit field. 1457 // 1458 BitOffset = IfrNumeric->Question.VarStoreInfo.VarOffset; 1459 BitWidth = IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT; 1460 Offset = BitOffset / 8; 1461 TotalBits = BitOffset % 8 + BitWidth; 1462 Width = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1); 1463 } else { 1464 Offset = IfrNumeric->Question.VarStoreInfo.VarOffset; 1465 Width = (UINT16) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE)); 1466 } 1276 1467 // 1277 1468 // Check whether this question is in current block array. … … 1297 1488 // 1298 1489 VarValue = 0; 1299 CopyMem (&VarValue, VarBuffer + Offset, Width); 1490 if (QuestionReferBitField) { 1491 // 1492 // Get the value in the bit fields. 1493 // 1494 StartBit = BitOffset % 8; 1495 EndBit = StartBit + BitWidth - 1; 1496 CopyMem ((UINT8 *) &BufferValue, VarBuffer + Offset, Width); 1497 VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit); 1498 } else { 1499 CopyMem (&VarValue, VarBuffer + Offset, Width); 1500 } 1300 1501 } 1301 switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { 1302 case EFI_IFR_NUMERIC_SIZE_1: 1303 if ((UINT8) VarValue < IfrNumeric->data.u8.MinValue || (UINT8) VarValue > IfrNumeric->data.u8.MaxValue) { 1304 // 1305 // Not in the valid range. 1306 // 1307 return EFI_INVALID_PARAMETER; 1502 if ( QuestionReferBitField) { 1503 // 1504 // Value in bit fields was stored as UINt32 type. 1505 // 1506 if ((IfrNumeric->Flags & EDKII_IFR_DISPLAY_BIT) == 0) { 1507 if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValue || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) { 1508 // 1509 // Not in the valid range. 1510 // 1511 return EFI_INVALID_PARAMETER; 1512 } 1513 } else { 1514 if (VarValue < IfrNumeric->data.u32.MinValue || VarValue > IfrNumeric->data.u32.MaxValue) { 1515 // 1516 // Not in the valid range. 1517 // 1518 return EFI_INVALID_PARAMETER; 1519 } 1520 } 1521 } else { 1522 if ((IfrNumeric->Flags & EFI_IFR_DISPLAY) == 0) { 1523 switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { 1524 case EFI_IFR_NUMERIC_SIZE_1: 1525 if ((INT8) VarValue < (INT8) IfrNumeric->data.u8.MinValue || (INT8) VarValue > (INT8) IfrNumeric->data.u8.MaxValue) { 1526 // 1527 // Not in the valid range. 1528 // 1529 return EFI_INVALID_PARAMETER; 1530 } 1531 break; 1532 case EFI_IFR_NUMERIC_SIZE_2: 1533 if ((INT16) VarValue < (INT16) IfrNumeric->data.u16.MinValue || (INT16) VarValue > (INT16) IfrNumeric->data.u16.MaxValue) { 1534 // 1535 // Not in the valid range. 1536 // 1537 return EFI_INVALID_PARAMETER; 1538 } 1539 break; 1540 case EFI_IFR_NUMERIC_SIZE_4: 1541 if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValue || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) { 1542 // 1543 // Not in the valid range. 1544 // 1545 return EFI_INVALID_PARAMETER; 1546 } 1547 break; 1548 case EFI_IFR_NUMERIC_SIZE_8: 1549 if ((INT64) VarValue < (INT64) IfrNumeric->data.u64.MinValue || (INT64) VarValue > (INT64) IfrNumeric->data.u64.MaxValue) { 1550 // 1551 // Not in the valid range. 1552 // 1553 return EFI_INVALID_PARAMETER; 1554 } 1555 break; 1556 } 1557 } else { 1558 switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) { 1559 case EFI_IFR_NUMERIC_SIZE_1: 1560 if ((UINT8) VarValue < IfrNumeric->data.u8.MinValue || (UINT8) VarValue > IfrNumeric->data.u8.MaxValue) { 1561 // 1562 // Not in the valid range. 1563 // 1564 return EFI_INVALID_PARAMETER; 1565 } 1566 break; 1567 case EFI_IFR_NUMERIC_SIZE_2: 1568 if ((UINT16) VarValue < IfrNumeric->data.u16.MinValue || (UINT16) VarValue > IfrNumeric->data.u16.MaxValue) { 1569 // 1570 // Not in the valid range. 1571 // 1572 return EFI_INVALID_PARAMETER; 1573 } 1574 break; 1575 case EFI_IFR_NUMERIC_SIZE_4: 1576 if ((UINT32) VarValue < IfrNumeric->data.u32.MinValue || (UINT32) VarValue > IfrNumeric->data.u32.MaxValue) { 1577 // 1578 // Not in the valid range. 1579 // 1580 return EFI_INVALID_PARAMETER; 1581 } 1582 break; 1583 case EFI_IFR_NUMERIC_SIZE_8: 1584 if ((UINT64) VarValue < IfrNumeric->data.u64.MinValue || (UINT64) VarValue > IfrNumeric->data.u64.MaxValue) { 1585 // 1586 // Not in the valid range. 1587 // 1588 return EFI_INVALID_PARAMETER; 1589 } 1590 break; 1591 } 1308 1592 } 1309 break;1310 case EFI_IFR_NUMERIC_SIZE_2:1311 if ((UINT16) VarValue < IfrNumeric->data.u16.MinValue || (UINT16) VarValue > IfrNumeric->data.u16.MaxValue) {1312 //1313 // Not in the valid range.1314 //1315 return EFI_INVALID_PARAMETER;1316 }1317 break;1318 case EFI_IFR_NUMERIC_SIZE_4:1319 if ((UINT32) VarValue < IfrNumeric->data.u32.MinValue || (UINT32) VarValue > IfrNumeric->data.u32.MaxValue) {1320 //1321 // Not in the valid range.1322 //1323 return EFI_INVALID_PARAMETER;1324 }1325 break;1326 case EFI_IFR_NUMERIC_SIZE_8:1327 if ((UINT64) VarValue < IfrNumeric->data.u64.MinValue || (UINT64) VarValue > IfrNumeric->data.u64.MaxValue) {1328 //1329 // Not in the valid range.1330 //1331 return EFI_INVALID_PARAMETER;1332 }1333 break;1334 1593 } 1335 1336 1594 break; 1337 1595 case EFI_IFR_CHECKBOX_OP: … … 1374 1632 // Get Offset by Question header 1375 1633 // 1376 Offset = IfrCheckBox->Question.VarStoreInfo.VarOffset; 1377 Width = (UINT16) sizeof (BOOLEAN); 1634 if (QuestionReferBitField) { 1635 // 1636 // Get the byte offset/width for bit field. 1637 // 1638 BitOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset; 1639 BitWidth = 1; 1640 Offset = BitOffset / 8; 1641 TotalBits = BitOffset % 8 + BitWidth; 1642 Width = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1); 1643 } else { 1644 Offset = IfrCheckBox->Question.VarStoreInfo.VarOffset; 1645 Width = (UINT16) sizeof (BOOLEAN); 1646 } 1378 1647 // 1379 1648 // Check whether this question is in current block array. … … 1398 1667 // 1399 1668 VarValue = 0; 1400 CopyMem (&VarValue, VarBuffer + Offset, Width); 1669 if (QuestionReferBitField) { 1670 // 1671 // Get the value in bit fields. 1672 // 1673 StartBit = BitOffset % 8; 1674 EndBit = StartBit + BitWidth - 1; 1675 CopyMem ((UINT8 *) &BufferValue, VarBuffer + Offset, Width); 1676 VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit); 1677 } else { 1678 CopyMem (&VarValue, VarBuffer + Offset, Width); 1679 } 1401 1680 } 1402 1681 // … … 1427 1706 } 1428 1707 // 1429 // Get Width by OneOf Flags1708 // Get the Max size of the string. 1430 1709 // 1431 1710 Width = (UINT16) (IfrString->MaxSize * sizeof (UINT16)); … … 1441 1720 break; 1442 1721 } 1722 // 1723 // Skip the VarName. 1724 // 1725 StringPtr += StrLen (QuestionName); 1443 1726 1444 1727 // … … 1449 1732 // 1450 1733 // Check current string length is less than maxsize 1451 // 1452 if (StrSize (StringPtr) > Width) { 1734 // e.g Config String: "0041004200430044", Unicode String: "ABCD". Unicode String length = Config String length / 4. 1735 // Config string format in UEFI spec. 1736 // <NvConfig> ::= <Label>'='<String> 1737 // <String> ::= [<Char>]+ 1738 // <Char> ::= <HexCh>4 1739 // 1740 if (StrLen (StringPtr) / 4 > IfrString->MaxSize) { 1453 1741 return EFI_INVALID_PARAMETER; 1454 1742 } … … 1480 1768 // Check current string length is less than maxsize 1481 1769 // 1482 if (Str Size ((CHAR16 *) (VarBuffer + Offset)) > Width) {1770 if (StrLen ((CHAR16 *) (VarBuffer + Offset)) > IfrString->MaxSize) { 1483 1771 return EFI_INVALID_PARAMETER; 1484 1772 } … … 1514 1802 break; 1515 1803 case EFI_IFR_END_OP: 1804 QuestionReferBitField = FALSE; 1516 1805 // 1517 1806 // Decrease opcode scope for the validated opcode … … 1526 1815 if ((VarBlockData.Scope == 0) && (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP)) { 1527 1816 return EFI_INVALID_PARAMETER; 1817 } 1818 break; 1819 case EFI_IFR_GUID_OP: 1820 if (CompareGuid ((EFI_GUID *)((UINT8*)IfrOpHdr + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) { 1821 QuestionReferBitField = TRUE; 1528 1822 } 1529 1823 break; … … 1551 1845 // Go to next package. 1552 1846 // 1553 PackageOffset += Pac akgeHeader.Length;1847 PackageOffset += PackageHeader.Length; 1554 1848 } 1555 1849 … … 1694 1988 // Check whether VarBuffer is enough 1695 1989 // 1696 if ((UINT N) (Offset + Width)> MaxBufferSize) {1990 if ((UINT32)Offset + Width > MaxBufferSize) { 1697 1991 DataBuffer = ReallocatePool ( 1698 1992 MaxBufferSize, … … 1948 2242 @param ActionType Action supports setting defaults and validate current setting. 1949 2243 1950 @retval T URE Action runs successfully.2244 @retval TRUE Action runs successfully. 1951 2245 @retval FALSE Action is not valid or Action can't be executed successfully.. 1952 2246 **/ … … 1976 2270 EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList; 1977 2271 UINTN PackageListLength; 2272 UINTN MaxLen; 1978 2273 EFI_DEVICE_PATH_PROTOCOL *DevicePath; 1979 2274 EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; … … 2020 2315 2021 2316 StringPtr = ConfigAltResp; 2022 2023 while (StringPtr != L'\0') { 2317 ASSERT (StringPtr != NULL); 2318 2319 while (*StringPtr != L'\0') { 2024 2320 // 2025 2321 // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=... … … 2231 2527 // | 1 | StrLen (ConfigHdr) | 8 | 1 | 2232 2528 // 2233 ConfigAltHdr = AllocateZeroPool ((1 + StringPtr - StringHdr + 8 + 1) * sizeof (CHAR16)); 2529 MaxLen = 1 + StringPtr - StringHdr + 8 + 1; 2530 ConfigAltHdr = AllocateZeroPool ( MaxLen * sizeof (CHAR16)); 2234 2531 if (ConfigAltHdr == NULL) { 2235 2532 Status = EFI_OUT_OF_RESOURCES; 2236 2533 goto Done; 2237 2534 } 2238 StrCpy (ConfigAltHdr, L"&");2239 StrnCat (ConfigAltHdr, StringHdr, StringPtr - StringHdr);2240 StrCat (ConfigAltHdr, L"&ALTCFG=");2535 StrCpyS (ConfigAltHdr, MaxLen, L"&"); 2536 StrnCatS (ConfigAltHdr, MaxLen, StringHdr, StringPtr - StringHdr); 2537 StrCatS (ConfigAltHdr, MaxLen, L"&ALTCFG="); 2241 2538 2242 2539 // … … 2340 2637 @param DefaultId Specifies the type of defaults to retrieve. 2341 2638 2342 @retval T URE The default value is set successfully.2639 @retval TRUE The default value is set successfully. 2343 2640 @retval FALSE The default value can't be found and set. 2344 2641 **/ … … 4045 4342 UINT8 *UpdateBufferPos; 4046 4343 EFI_HII_PACKAGE_HEADER *Package; 4047 EFI_HII_PACKAGE_HEADER *TempPac akge;4344 EFI_HII_PACKAGE_HEADER *TempPackage; 4048 4345 EFI_HII_PACKAGE_HEADER PackageHeader; 4049 4346 BOOLEAN Updated; … … 4057 4354 ASSERT (StartOpCodeHandle != NULL); 4058 4355 UpdatePackageList = NULL; 4059 TempPac akge = NULL;4356 TempPackage = NULL; 4060 4357 HiiPackageList = NULL; 4061 4358 … … 4103 4400 // Allocate temp buffer to store the temp updated package buffer 4104 4401 // 4105 TempPac akge = AllocateZeroPool (BufferSize);4106 if (TempPac akge == NULL) {4402 TempPackage = AllocateZeroPool (BufferSize); 4403 if (TempPackage == NULL) { 4107 4404 Status = EFI_OUT_OF_RESOURCES; 4108 4405 goto Finish; … … 4132 4429 // Check this package is the matched package. 4133 4430 // 4134 Status = InternalHiiUpdateFormPackageData (FormSetGuid, FormId, Package, OpCodeBufferStart, OpCodeBufferEnd, TempPac akge);4431 Status = InternalHiiUpdateFormPackageData (FormSetGuid, FormId, Package, OpCodeBufferStart, OpCodeBufferEnd, TempPackage); 4135 4432 // 4136 4433 // The matched package is found. Its package buffer will be updated by the input new data. … … 4144 4441 // Add updated package buffer 4145 4442 // 4146 Package = TempPac akge;4443 Package = TempPackage; 4147 4444 } 4148 4445 } … … 4183 4480 } 4184 4481 4185 if (TempPac akge != NULL) {4186 FreePool (TempPac akge);4482 if (TempPackage != NULL) { 4483 FreePool (TempPackage); 4187 4484 } 4188 4485
Note:
See TracChangeset
for help on using the changeset viewer.