Detect bad b_info.method

https://issues.oss-fuzz.com/u/1/issues?q=upx
	modified:   p_lx_elf.cpp
	modified:   p_unix.cpp
	modified:   packhead.cpp
	modified:   packhead.h
This commit is contained in:
John Reiser
2025-02-20 09:00:25 -08:00
parent 896dff9619
commit 8cce9cf641
4 changed files with 22 additions and 14 deletions
+7
View File
@@ -45,6 +45,13 @@ void PackHeader::reset() noexcept {
compress_result.reset();
}
int PackHeader::set_method(int m, unsigned offset) {
unsigned mc = ~(0x80u << 24) & m; // see ph_forced_method
if ((mc < M_NRV2B_LE32 || M_LZMA < mc) && ~0u != offset)
throwCantPack("bad method %#x at %#x", (unsigned) m, offset);
return method = m;
}
/*************************************************************************
// extremely simple checksum for the header itself (since version 10)
**************************************************************************/