Commit Graph

256 Commits

Author SHA1 Message Date
John Reiser
c0e40da2ab more checking of Mach_header when unpacking for MachOS
https://github.com/upx/upx/issues/783
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65532
	modified:   p_mach.cpp
2024-01-27 14:16:53 -08:00
John Reiser
f3728d99b9 Check ph.method in PackMachBase::unpack
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65553
https://github.com/upx/upx/issues/766
	modified:   p_mach.cpp
2024-01-10 16:04:08 -08:00
John Reiser
b87f60a917 Check Mach_fat_arch.align
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65558
https://github.com/upx/upx/issues/765
	modified:   p_mach.cpp
2024-01-10 15:31:37 -08:00
John Reiser
28f26da6ab Need more care in PackMachBase::canUnpack()
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65532
https://github.com/upx/upx/issues/764
	modified:   p_mach.cpp
2024-01-10 15:14:54 -08:00
Markus F.X.J. Oberhumer
47fc230893 all: welcome 2024 2024-01-03 17:47:25 +01:00
John Reiser
ae77fd60bb initial headway is limited by both file_size and mhcmdi.sizeofcmds
https://github.com/upx/upx/issues/732
	modified:   p_mach.cpp
2023-11-17 07:28:21 -08:00
Markus F.X.J. Oberhumer
4f0f977f04 CI updates and cleanups 2023-11-03 17:52:46 +01:00
Markus F.X.J. Oberhumer
facabd68d7 all: more minor cleanups 2023-10-24 23:56:55 +02:00
Markus F.X.J. Oberhumer
4870765e1b all: disable packing macOS binaries for now 2023-10-15 10:15:46 +02:00
Markus F.X.J. Oberhumer
62dbf8485f src: sort cleanups 2023-09-04 07:28:48 +02:00
Markus F.X.J. Oberhumer
a00687b092 src/p_mach.cpp: make sort order deterministic 2023-09-01 11:11:00 +02:00
Markus F.X.J. Oberhumer
cfa8107ab9 src: make sort order deterministic, next try
We cannot compare pointers as they may point to qsort-local objects.
And we must make sure that cmp(a,b) always agrees with cmp(b,a).
2023-08-30 16:41:59 +02:00
Markus F.X.J. Oberhumer
f4e5b29708 src: make sort order deterministic 2023-08-28 02:08:34 +02:00
Markus F.X.J. Oberhumer
a9ac4b5e23 src: introduce type tribool 2023-08-15 14:44:50 +02:00
John Reiser
43b3b54197 spell check typos
modified:   p_lx_exc.cpp
	modified:   p_mach.cpp
	modified:   stub/src/amd64-linux.elf-so_main.c
	modified:   stub/src/i386-linux.elf-so_main.c
	modified:   stub/src/arch/mips/r3000/bits.ash
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm.v4a-linux.shlib-init.S
	modified:   stub/src/arm64-linux.shlib-init.S
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
2023-07-31 09:05:32 -07:00
Markus F.X.J. Oberhumer
70287d3c49 clang-tidy 2023-07-31 14:49:48 +02:00
John Reiser
d8395d8c42 Fix usage of _te32/_te64/_te16 for Elf classes
How did it ever work?  UPX_RSIZE_MAX_MEM of 768MiB, Elf32_Off of only
32-bits, and preponderance of little-endian and small positive integers
hides many mis-uses of _te64/_te32.
ELF does not help: e_phnum, e_shnum, Elf32_Section, Elf64_Section are all
16-bit, but sh_info and sh_link are 32-bit.
Templatizing p_elf.h (following the example of p_mach.h) failed
because of complexity.  (Plus too many special cases of ELF where 32-bit
and 64-bit are not parallel.)
	modified:   p_lx_elf.cpp
	modified:   p_lx_sh.cpp
	modified:   p_mach.cpp
2023-04-17 13:19:06 -07:00
Markus F.X.J. Oberhumer
b8d9c2b755 all: assorted updates and cleanups 2023-02-05 17:20:32 +01:00
Markus F.X.J. Oberhumer
dd1d5a92d2 all: welcome 2023 2023-01-01 19:49:30 +01:00
John Reiser
77ba43328b Use my_page_size, which is 0x4000 (16KiB) on arm64
https://github.com/upx/upx/issues/628
	modified:   p_mach.cpp
2022-12-31 20:55:34 +01:00
John Reiser
01a30752c7 Mach-O: allow 256 ncmds and 32768 sizeofcmds
https://github.com/upx/upx/issues/642
	modified:   p_mach.cpp
	modified:   stub/src/i386-darwin.macho-upxmain.c
	modified:   stub/src/powerpc-darwin.macho-upxmain.c
2022-12-29 14:02:42 -08:00
Markus F.X.J. Oberhumer
9934e33b99 src: pacify a clang scan-build warning in p_mach.cpp 2022-12-12 21:27:34 +01:00
John Reiser
72613d06a5 Look for PackHeader in the right place.
https://github.com/upx/upx/issues/606
	modified:   p_mach.cpp
2022-10-11 08:08:55 -07:00
John Reiser
1e8f1f49d0 is_bad_linker_command() ignores LC_REQ_DYLD
https://github.com/upx/upx/issues/606
	modified:   p_mach.cpp
2022-10-06 10:15:10 -07:00
John Reiser
d0a52bd483 More cleanup of stubs for powerpc64le-darwin* which does not exist.
Only powerpc64-darwin (BigEndian, no suffix) exists.
https://github.com/upx/upx/issues/596
2022-09-27 15:58:35 +02:00
Markus F.X.J. Oberhumer
c75d7a685d src: major cleanups, introduce new eXtended Span class
- initial minimally invasive eXtended Span implementation
- rename ptr_diff to ptr_diff_bytes
- move some files to util subdir
- lots of cleanups
- start using the new checked pointers - this needs some real-world testing
2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer
d001a63bce Welcome 2022. 2022-09-04 04:24:39 +02:00
Markus F.X.J. Oberhumer
0d3377f48b src: p_mach.cpp: disable -Wcast-align warning 2022-08-17 19:54:44 +02:00
John Reiser
aeb04d97c8 powerpc64-darwin.macho (not powerpc64le-darwin.macho)
All Apple PowerPC are BigEndian only.
        https://github.com/upx/upx/issues/596
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   packmast.cpp
2022-09-03 12:39:50 -07:00
John Reiser
3b4627e17e Add filename to infoWarning("file coruupted")
modified:   p_mach.cpp
2022-06-01 08:34:23 -07:00
John Reiser
05976ee1a7 Try harder to de-compress corrupted Mach-o file.
https://github.com/upx/upx/issues/579
	modified:   p_mach.cpp
2022-05-31 11:52:10 -07:00
John Reiser
4ae75375e0 LC_BUILD_VERSION etc for XCode 13+
https://github.com/upx/upx/issues/578
	modified:   p_mach.cpp
	modified:   p_mach_enum.h
2022-05-30 01:05:09 -07:00
John Reiser
f204670008 Mach unpack checks for bad load_command in compressed input
https://github.com/upx/upx/issues/564
	modified:   p_mach.cpp
2022-02-25 10:17:04 -08:00
John Reiser
651155c64d Check Mach_header.ncmds at unpack
https://github.com/upx/upx/issues/563
	modified:   p_mach.cpp
2022-02-25 09:32:29 -08:00
John Reiser
2d6987252e is_bad_linker_command()
https://github.com/upx/upx/issues/545
	modified:   p_mach.cpp
2021-12-27 08:14:19 -08:00
John Reiser
4a9c46253e Validate input LC_ commands in order to defend against fuzzers
TODO: validate in ::unpack(), too
https://github.com/upx/upx/issues/545
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
2021-12-26 19:40:34 -08:00
John Reiser
766fe466d6 PAGE_SIZE varies: Apple M1 uses 16K
modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
2021-04-11 15:19:24 -07:00
goushibee
bf957f435e fix issue 486 2021-04-07 15:40:13 +08:00
John Reiser
7e5e6012df PackMachFat::canPack handles case PackMachFat::CPU_TYPE_ARM64
modified:   p_mach.cpp
2021-03-06 09:59:51 -08:00
John Reiser
fb844a8ed1 total_in, total_out move to PackUnix
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_lx_interp.cpp
	modified:   p_mach.cpp
	modified:   p_unix.cpp
	modified:   p_unix.h
2021-02-22 16:13:40 -08:00
John Reiser
23f63e4196 WIP unpacking ELF shared library
modified:   Makefile
	modified:   lzma-sdk
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_mach.cpp
	modified:   p_unix.cpp
	modified:   p_unix.h
	modified:   packer.cpp
	modified:   packer.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/tmp/arm64-linux.elf-fold.map
2021-01-15 14:11:09 -08:00
John Reiser
fd6837b267 Another checkAlreadyPacked()
https://github.com/upx/upx/issues/463
	modified:   Makefile
	modified:   p_mach.cpp
2021-02-26 15:15:28 -08:00
John Reiser
1ab6e01de2 MacOS BigSur wants no MH_DYLDLINK for our MH_EXECUTE
https://github.com/upx/upx/issues/434
	modified:   p_mach.cpp
2021-02-14 13:23:19 -08:00
John Reiser
2469563b26 Mach_ARM64_thread_state padded to (0 mod 8)
https://github.com/upx/upx/issues/446  (partial)
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
2021-01-30 16:11:32 -08:00
John Reiser
21d102c84f Better checking of Mach_header.ncmds, .sizeofcmds
Improves earlier fix.
https://github.com/upx/upx/issues/447
	modified:   p_mach.cpp
2021-01-23 13:52:54 -08:00
John Reiser
80de11bc5b Detect Mach_header.sizeofcmds==0
https://github.com/upx/upx/issues/448
	modified:   p_mach.cpp
2021-01-17 17:09:35 -08:00
John Reiser
5f98bb0ab0 De-compress allows old-style LC_UNIXTHREAD with one LC_SEGMENT
https://github.com/upx/upx/issues/447
	modified:   p_mach.cpp
2021-01-15 15:03:26 -08:00
Markus F.X.J. Oberhumer
9131d5216f Welcome 2021. 2021-01-01 20:39:22 +01:00
Markus F.X.J. Oberhumer
f7e2266c3f Start using some C++ 14 features. 2020-12-08 05:40:17 +01:00
Markus F.X.J. Oberhumer
bd193201b2 Avoid a clang-11 warning. 2020-12-03 02:14:47 +01:00