SWDEV-465203 - Treat 0 elf length images as invalid

This addresses:
SWDEV-465203
SWDEV-465202

Change-Id: I49fcdd537fd07585e25c5fdef37cd10815466f79
This commit is contained in:
Branislav Brzak authored and Branislav Brzak committed 2024-06-14 04:56:43 -04:00
1 parent d12af175af
commit f014124527
1 file changed
+6 -1
+6 -1
View File
@@ -175,8 +175,13 @@ hipError_t FatBinaryInfo::ExtractFatBinaryUsingCOMGR(const std::vector<hip::Devi
// If the image ptr is not clang offload bundle then just directly point the image.
if (!CodeObject::IsClangOffloadMagicBundle(image_, isCompressed)) {
for (size_t dev_idx=0; dev_idx < devices.size(); ++dev_idx) {
uint64_t elf_size = CodeObject::ElfSize(image_);
if (elf_size == 0) {
hip_status = hipErrorInvalidImage;
break;
}
fatbin_dev_info_[devices[dev_idx]->deviceId()]
= new FatBinaryDeviceInfo(image_, CodeObject::ElfSize(image_), 0);
= new FatBinaryDeviceInfo(image_, elf_size, 0);
fatbin_dev_info_[devices[dev_idx]->deviceId()]->program_
= new amd::Program(*devices[dev_idx]->asContext());
if (fatbin_dev_info_[devices[dev_idx]->deviceId()]->program_ == nullptr) {