Detect bad placement of LINK segment

https://github.com/upx/upx/issues/827
	modified:   p_mach.cpp
This commit is contained in:
John Reiser 2024-06-04 08:55:46 -07:00
parent c58246b43c
commit 056865f59a
1 changed files with 4 additions and 0 deletions

View File

@ -1754,6 +1754,10 @@ tribool PackMachBase<T>::canUnpack()
else { // PackHeader follows loader at __LINKEDIT
if ((off_t)bufsize > (fi->st_size() - offLINK)) {
bufsize = fi->st_size() - offLINK;
if (bufsize < sizeof(struct b_info)) {
throwCantUnpack("bad offLINK %p %p",
(void *)offLINK, (void *)file_size);
}
}
fi->seek(offLINK, SEEK_SET);
}