| 717 | } |
| 718 | |
| 719 | EFI_STATUS |
| 720 | Decompress ( |
| 721 | IN VOID *Source, |
| 722 | IN UINT32 SrcSize, |
| 723 | IN OUT VOID *Destination, |
| 724 | IN UINT32 DstSize, |
| 725 | IN OUT VOID *Scratch, |
| 726 | IN UINT32 ScratchSize |
| 727 | ) |
| 728 | /*++ |
| 729 | |
| 730 | Routine Description: |
| 731 | |
| 732 | The implementation Efi and Tiano Decompress(). |
| 733 | |
| 734 | Arguments: |
| 735 | |
| 736 | Source - The source buffer containing the compressed data. |
| 737 | SrcSize - The size of source buffer |
| 738 | Destination - The destination buffer to store the decompressed data |
| 739 | DstSize - The size of destination buffer. |
| 740 | Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data. |
| 741 | ScratchSize - The size of scratch buffer. |
| 742 | |
| 743 | Returns: |
| 744 | |
| 745 | EFI_SUCCESS - Decompression is successful |
| 746 | EFI_INVALID_PARAMETER - The source data is corrupted |
| 747 | |
| 748 | --*/ |
| 749 | { |
| 750 | UINT32 Index; |
| 751 | UINT32 CompSize; |
| 752 | UINT32 OrigSize; |
| 753 | EFI_STATUS Status; |
| 754 | SCRATCH_DATA *Sd; |
| 755 | UINT8 *Src; |
| 756 | UINT8 *Dst; |
| 757 | |
| 758 | Status = EFI_SUCCESS; |
| 759 | Src = Source; |
| 760 | Dst = Destination; |
| 761 | |
| 762 | if (ScratchSize < sizeof (SCRATCH_DATA)) { |
| 763 | return EFI_INVALID_PARAMETER; |
| 764 | } |
| 765 | |
| 766 | Sd = (SCRATCH_DATA *) Scratch; |
| 767 | |
| 768 | if (SrcSize < 8) { |
| 769 | return EFI_INVALID_PARAMETER; |
| 770 | } |
| 771 | |
| 772 | CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24); |
| 773 | OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); |
| 774 | |
| 775 | if (SrcSize < CompSize + 8 || (CompSize + 8) < 8) { |
| 776 | return EFI_INVALID_PARAMETER; |
no test coverage detected