]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenFw/Elf64Convert.c
BaseTools: Fix Section header size larger than elf file size bug
[mirror_edk2.git] / BaseTools / Source / C / GenFw / Elf64Convert.c
index 54011d75f1ec6c9951071be5b5261a091200e058..9ffb367e4365b39588c3008335dfdc2d210a68d5 100644 (file)
@@ -670,6 +670,9 @@ WriteSections64 (
       switch (Shdr->sh_type) {\r
       case SHT_PROGBITS:\r
         /* Copy.  */\r
+        if (Shdr->sh_offset + Shdr->sh_size > mFileBufferSize) {\r
+          return FALSE;\r
+        }\r
         memcpy(mCoffFile + mCoffSectionsOffset[Idx],\r
               (UINT8*)mEhdr + Shdr->sh_offset,\r
               (size_t) Shdr->sh_size);\r