1
0
mirror of https://github.com/upx/upx synced 2025-10-05 19:20:23 +08:00

un_shlib_1() allows test mode ("-t") which has (nullptr == fo)

modified:   p_lx_elf.cpp
This commit is contained in:
John Reiser 2022-10-07 12:52:21 -07:00 committed by Markus F.X.J. Oberhumer
parent 201d9f1346
commit 48ad5513ff

View File

@ -4893,9 +4893,11 @@ void PackLinuxElf64::un_shlib_1(
c_adler, u_adler, false, szb_info); c_adler, u_adler, false, szb_info);
// Recover original Elf headers from current output file // Recover original Elf headers from current output file
InputFile u_fi; InputFile u_fi;
u_fi.open(fo->getName(), 0); if (fo) {
u_fi.readx((void *)o_elfhdrs,o_elfhdrs.getSize()); u_fi.open(fo->getName(), 0);
u_fi.close(); u_fi.readx((void *)o_elfhdrs,o_elfhdrs.getSize());
u_fi.close();
}
Elf64_Phdr const *t_phdr = (Elf64_Phdr const *)(1+ (Elf64_Ehdr const *)(void const *)o_elfhdrs); Elf64_Phdr const *t_phdr = (Elf64_Phdr const *)(1+ (Elf64_Ehdr const *)(void const *)o_elfhdrs);
unsigned t_flags = get_te32(&t_phdr->p_flags); unsigned t_flags = get_te32(&t_phdr->p_flags);
@ -4938,8 +4940,10 @@ void PackLinuxElf64::un_shlib_1(
fi->seek(i_offset, SEEK_SET); fi->seek(i_offset, SEEK_SET);
fi->readx(ibuf, filesz); fi->readx(ibuf, filesz);
total_in += filesz; total_in += filesz;
fo->seek(o_offset, SEEK_SET); if (fo) {
fo->write(ibuf, filesz); fo->seek(o_offset, SEEK_SET);
fo->write(ibuf, filesz);
}
total_out = filesz + o_offset; // high-water mark total_out = filesz + o_offset; // high-water mark
} }
} }
@ -4947,8 +4951,10 @@ void PackLinuxElf64::un_shlib_1(
} }
} }
else { // Old style else { // Old style
Elf64_Phdr const *o_phdr = (Elf64_Phdr const *)(1+ (Elf64_Ehdr const *)(void const *)o_elfhdrs); if (fo) {
fi->seek(o_phdr->p_offset, SEEK_CUR); // DEBUG no-op Elf64_Phdr const *o_phdr = (Elf64_Phdr const *)(1+ (Elf64_Ehdr const *)(void const *)o_elfhdrs);
fi->seek(o_phdr->p_offset, SEEK_CUR); // DEBUG no-op
}
} }
// position fi at loader offset // position fi at loader offset