SWDEV-465203 - Treat 0 elf length images as invalid

This addresses:
SWDEV-465203
SWDEV-465202

Change-Id: I49fcdd537fd07585e25c5fdef37cd10815466f79


[ROCm/clr commit: f014124527]
This commit is contained in:
Branislav Brzak
2024-06-06 02:54:57 -07:00
committed by Branislav Brzak
parent 8b557c7318
commit c2128d0af9
+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) {