/* Iterates through the sections contained within a given array of sections */
EFI_STATUS FvBufFindNextSection(IN VOID *SectionsStart, IN UINTN TotalSectionsSize, IN OUT UINTN *Key, OUT VOID **Section)
/* Iterates through the sections contained within a given array of sections */
EFI_STATUS FvBufFindNextSection(IN VOID *SectionsStart, IN UINTN TotalSectionsSize, IN OUT UINTN *Key, OUT VOID **Section)
{
  EFI_COMMON_SECTION_HEADER *sectionHdr;
  UINTN sectionSize;
  *Key = (UINTN)ALIGN_POINTER (*Key, 4);
  if ((*Key + sizeof (*sectionHdr)) > TotalSectionsSize) {
    return EFI_NOT_FOUND;
  }
  sectionHdr = (EFI_COMMON_SECTION_HEADER*)((UINT8*)SectionsStart + *Key);
  sectionSize = FvBufGetSecFileLen (sectionHdr);
  if (sectionSize < sizeof (EFI_COMMON_SECTION_HEADER)) {
    return EFI_NOT_FOUND;
  }
  if ((*Key + sectionSize) > TotalSectionsSize) {
    return EFI_NOT_FOUND;
  }
  *Section = (UINT8*)sectionHdr;
  *Key = *Key + sectionSize;
  return EFI_SUCCESS;
}