| 360 | } |
| 361 | |
| 362 | EFI_STATUS |
| 363 | StringToGuid ( |
| 364 | IN CHAR8 *AsciiGuidBuffer, |
| 365 | OUT EFI_GUID *GuidBuffer |
| 366 | ) |
| 367 | /*++ |
| 368 | |
| 369 | Routine Description: |
| 370 | |
| 371 | Converts a string to an EFI_GUID. The string must be in the |
| 372 | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format. |
| 373 | |
| 374 | Arguments: |
| 375 | |
| 376 | AsciiGuidBuffer - pointer to ascii string |
| 377 | GuidBuffer - pointer to destination Guid |
| 378 | |
| 379 | Returns: |
| 380 | |
| 381 | EFI_ABORTED Could not convert the string |
| 382 | EFI_SUCCESS The string was successfully converted |
| 383 | EFI_INVALID_PARAMETER Input parameter is invalid. |
| 384 | |
| 385 | --*/ |
| 386 | { |
| 387 | INT32 Index; |
| 388 | int Data1; |
| 389 | int Data2; |
| 390 | int Data3; |
| 391 | int Data4[8]; |
| 392 | |
| 393 | if (AsciiGuidBuffer == NULL || GuidBuffer == NULL) { |
| 394 | return EFI_INVALID_PARAMETER; |
| 395 | } |
| 396 | // |
| 397 | // Check Guid Format strictly xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| 398 | // |
| 399 | for (Index = 0; AsciiGuidBuffer[Index] != '\0' && Index < 37; Index ++) { |
| 400 | if (Index == 8 || Index == 13 || Index == 18 || Index == 23) { |
| 401 | if (AsciiGuidBuffer[Index] != '-') { |
| 402 | break; |
| 403 | } |
| 404 | } else { |
| 405 | if (((AsciiGuidBuffer[Index] >= '0') && (AsciiGuidBuffer[Index] <= '9')) || |
| 406 | ((AsciiGuidBuffer[Index] >= 'a') && (AsciiGuidBuffer[Index] <= 'f')) || |
| 407 | ((AsciiGuidBuffer[Index] >= 'A') && (AsciiGuidBuffer[Index] <= 'F'))) { |
| 408 | continue; |
| 409 | } else { |
| 410 | break; |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | if (Index < 36 || AsciiGuidBuffer[36] != '\0') { |
| 416 | Error (NULL, 0, 1003, "Invalid option value", "Incorrect GUID \"%s\"\n Correct Format \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"", AsciiGuidBuffer); |
| 417 | return EFI_ABORTED; |
| 418 | } |
| 419 |
no test coverage detected