diff --git a/.gitignore b/.gitignore index 954d913..16b1e9e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ lzma465.tar.bz2 /upx-lzma-sdk-3.95.tar.gz /upx-3.96-src.tar.xz /upx-lzma-sdk-3.96.tar.gz +/upx-4.0.0-src.tar.xz diff --git a/2fcaa16c13eda34307ccceea2263e474c54ee075.patch b/2fcaa16c13eda34307ccceea2263e474c54ee075.patch deleted file mode 100644 index 30a7615..0000000 --- a/2fcaa16c13eda34307ccceea2263e474c54ee075.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 2fcaa16c13eda34307ccceea2263e474c54ee075 Mon Sep 17 00:00:00 2001 -From: Mattiwatti -Date: Tue, 21 Jan 2020 16:03:40 +0100 -Subject: [PATCH] Make PE load config directory address dword aligned - ---- - src/pefile.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/pefile.cpp b/src/pefile.cpp -index 7bf66cbe..d957886f 100644 ---- a/src/pefile.cpp -+++ b/src/pefile.cpp -@@ -2427,7 +2427,7 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, - processTls(&rel,&tlsiv,ic); - ODADDR(PEDIR_TLS) = sotls ? ic : 0; - ODSIZE(PEDIR_TLS) = sotls ? (sizeof(LEXX) == 4 ? 0x18 : 0x28) : 0; -- ic += sotls; -+ ic = ALIGN_UP(ic + sotls, 4u); - - processLoadConf(&rel, &loadconfiv, ic); - ODADDR(PEDIR_LOADCONF) = soloadconf ? ic : 0; diff --git a/3781df9da23840e596d5e9e8493f22666802fe6c.patch b/3781df9da23840e596d5e9e8493f22666802fe6c.patch deleted file mode 100644 index 1d47b2a..0000000 --- a/3781df9da23840e596d5e9e8493f22666802fe6c.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 3781df9da23840e596d5e9e8493f22666802fe6c Mon Sep 17 00:00:00 2001 -From: John Reiser -Date: Fri, 11 Dec 2020 13:38:18 -0800 -Subject: [PATCH] Check DT_REL/DT_RELA, DT_RELSZ/DT_RELASZ - -https://github.com/upx/upx/issues/421 - modified: p_lx_elf.cpp ---- - src/p_lx_elf.cpp | 34 +++++++++++++++++++++++++++++----- - 1 file changed, 29 insertions(+), 5 deletions(-) - -diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp -index 182db192..3a4101cf 100644 ---- a/src/p_lx_elf.cpp -+++ b/src/p_lx_elf.cpp -@@ -2222,8 +2222,20 @@ bool PackLinuxElf32::canPack() - int z_rsz = dt_table[Elf32_Dyn::DT_RELSZ]; - if (z_rel && z_rsz) { - unsigned rel_off = get_te32(&dynseg[-1+ z_rel].d_val); -+ if ((unsigned)file_size <= rel_off) { -+ char msg[70]; snprintf(msg, sizeof(msg), -+ "bad Elf32_Dynamic[DT_REL] %#x\n", -+ rel_off); -+ throwCantPack(msg); -+ } - Elf32_Rel *rp = (Elf32_Rel *)&file_image[rel_off]; - unsigned relsz = get_te32(&dynseg[-1+ z_rsz].d_val); -+ if ((unsigned)file_size <= relsz) { -+ char msg[70]; snprintf(msg, sizeof(msg), -+ "bad Elf32_Dynamic[DT_RELSZ] %#x\n", -+ relsz); -+ throwCantPack(msg); -+ } - Elf32_Rel *last = (Elf32_Rel *)(relsz + (char *)rp); - for (; rp < last; ++rp) { - unsigned r_va = get_te32(&rp->r_offset); -@@ -2562,14 +2574,26 @@ PackLinuxElf64::canPack() - int z_rel = dt_table[Elf64_Dyn::DT_RELA]; - int z_rsz = dt_table[Elf64_Dyn::DT_RELASZ]; - if (z_rel && z_rsz) { -- unsigned rel_off = get_te64(&dynseg[-1+ z_rel].d_val); -+ upx_uint64_t rel_off = get_te64(&dynseg[-1+ z_rel].d_val); -+ if ((u64_t)file_size <= rel_off) { -+ char msg[70]; snprintf(msg, sizeof(msg), -+ "bad Elf64_Dynamic[DT_RELA] %#llx\n", -+ rel_off); -+ throwCantPack(msg); -+ } - Elf64_Rela *rp = (Elf64_Rela *)&file_image[rel_off]; -- unsigned relsz = get_te64(&dynseg[-1+ z_rsz].d_val); -+ upx_uint64_t relsz = get_te64(&dynseg[-1+ z_rsz].d_val); -+ if ((u64_t)file_size <= relsz) { -+ char msg[70]; snprintf(msg, sizeof(msg), -+ "bad Elf64_Dynamic[DT_RELASZ] %#llx\n", -+ relsz); -+ throwCantPack(msg); -+ } - Elf64_Rela *last = (Elf64_Rela *)(relsz + (char *)rp); - for (; rp < last; ++rp) { -- unsigned r_va = get_te64(&rp->r_offset); -+ upx_uint64_t r_va = get_te64(&rp->r_offset); - if (r_va == user_init_ava) { // found the Elf64_Rela -- unsigned r_info = get_te64(&rp->r_info); -+ upx_uint64_t r_info = get_te64(&rp->r_info); - unsigned r_type = ELF64_R_TYPE(r_info); - if (Elf64_Ehdr::EM_AARCH64 == e_machine - && R_AARCH64_RELATIVE == r_type) { -@@ -2581,7 +2605,7 @@ PackLinuxElf64::canPack() - } - else { - char msg[50]; snprintf(msg, sizeof(msg), -- "bad relocation %#x DT_INIT_ARRAY[0]", -+ "bad relocation %#llx DT_INIT_ARRAY[0]", - r_info); - throwCantPack(msg); - } diff --git a/87b73e5cfdc12da94c251b2cd83bb01c7d9f616c.patch b/87b73e5cfdc12da94c251b2cd83bb01c7d9f616c.patch deleted file mode 100644 index 7e6de04..0000000 --- a/87b73e5cfdc12da94c251b2cd83bb01c7d9f616c.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 87b73e5cfdc12da94c251b2cd83bb01c7d9f616c Mon Sep 17 00:00:00 2001 -From: John Reiser -Date: Wed, 22 Jul 2020 19:34:27 -0700 -Subject: [PATCH] Unpack: Phdrs must be within expansion of first compressed - block - -https://github.com/upx/upx/issues/388 - modified: p_lx_elf.cpp ---- - src/p_lx_elf.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp -index cd9e4ec97..453d5c457 100644 ---- a/src/p_lx_elf.cpp -+++ b/src/p_lx_elf.cpp -@@ -4550,7 +4550,7 @@ void PackLinuxElf64::unpack(OutputFile *fo) - unsigned c_adler = upx_adler32(NULL, 0); - unsigned u_adler = upx_adler32(NULL, 0); - #define MAX_ELF_HDR 1024 -- if ((MAX_ELF_HDR - sizeof(Elf64_Ehdr))/sizeof(Elf64_Phdr) < u_phnum) { -+ if ((umin64(MAX_ELF_HDR, ph.u_len) - sizeof(Elf64_Ehdr))/sizeof(Elf64_Phdr) < u_phnum) { - throwCantUnpack("bad compressed e_phnum"); - } - #undef MAX_ELF_HDR -@@ -5617,7 +5617,7 @@ void PackLinuxElf32::unpack(OutputFile *fo) - unsigned c_adler = upx_adler32(NULL, 0); - unsigned u_adler = upx_adler32(NULL, 0); - #define MAX_ELF_HDR 512 -- if ((MAX_ELF_HDR - sizeof(Elf32_Ehdr))/sizeof(Elf32_Phdr) < u_phnum) { -+ if ((umin(MAX_ELF_HDR, ph.u_len) - sizeof(Elf32_Ehdr))/sizeof(Elf32_Phdr) < u_phnum) { - throwCantUnpack("bad compressed e_phnum"); - } - #undef MAX_ELF_HDR diff --git a/dadfd43ecb9909b0fab18e77753953a91322c628.patch b/dadfd43ecb9909b0fab18e77753953a91322c628.patch deleted file mode 100644 index 1143325..0000000 --- a/dadfd43ecb9909b0fab18e77753953a91322c628.patch +++ /dev/null @@ -1,127 +0,0 @@ -From dadfd43ecb9909b0fab18e77753953a91322c628 Mon Sep 17 00:00:00 2001 -From: John Reiser -Date: Fri, 17 Apr 2020 16:17:29 -0700 -Subject: [PATCH] --preserve-build-id for ET_EXEC - -https://github.com/upx/upx/issues/371 - modified: p_lx_elf.cpp ---- - src/p_lx_elf.cpp | 50 +++++++++++++++++++++++++++++++----------------- - 1 file changed, 32 insertions(+), 18 deletions(-) - -diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp -index 6b5b4295..725f68f4 100644 ---- a/src/p_lx_elf.cpp -+++ b/src/p_lx_elf.cpp -@@ -3386,26 +3386,33 @@ void PackLinuxElf32::pack1(OutputFile *fo, Filter & /*ft*/) - if (opt->o_unix.preserve_build_id) { - // set this so we can use elf_find_section_name - e_shnum = get_te16(&ehdri.e_shnum); -+ MemBuffer mb_shdri; - if (!shdri) { -- shdri = (Elf32_Shdr *)&file_image[get_te32(&ehdri.e_shoff)]; -+ mb_shdri.alloc(e_shnum * sizeof(Elf32_Shdr)); -+ shdri = (Elf32_Shdr *)mb_shdri.getVoidPtr(); -+ e_shoff = get_te32(&ehdri.e_shoff); -+ fi->seek(e_shoff, SEEK_SET); -+ fi->readx(shdri, e_shnum * sizeof(Elf32_Shdr)); - } - //set the shstrtab - sec_strndx = &shdri[get_te16(&ehdri.e_shstrndx)]; - -- char *strtab = New(char, sec_strndx->sh_size); -+ unsigned sh_size = get_te32(&sec_strndx->sh_size); -+ char *strtab = New(char, sh_size); - fi->seek(0,SEEK_SET); - fi->seek(sec_strndx->sh_offset,SEEK_SET); -- fi->readx(strtab,sec_strndx->sh_size); -+ fi->readx(strtab, sh_size); - - shstrtab = (const char*)strtab; - - Elf32_Shdr const *buildid = elf_find_section_name(".note.gnu.build-id"); - if (buildid) { -- unsigned char *data = New(unsigned char, buildid->sh_size); -- memset(data,0,buildid->sh_size); -+ unsigned bid_sh_size = get_te32(&buildid->sh_size); -+ unsigned char *data = New(unsigned char, bid_sh_size); -+ memset(data,0,bid_sh_size); - fi->seek(0,SEEK_SET); - fi->seek(buildid->sh_offset,SEEK_SET); -- fi->readx(data,buildid->sh_size); -+ fi->readx(data, bid_sh_size); - - buildid_data = data; - -@@ -3414,12 +3421,12 @@ void PackLinuxElf32::pack1(OutputFile *fo, Filter & /*ft*/) - - //setup the build-id - memcpy(&shdrout.shdr[1], buildid, sizeof(shdrout.shdr[1])); -- shdrout.shdr[1].sh_name = 1; -+ set_te32(&shdrout.shdr[1].sh_name, 1); - - //setup the shstrtab - memcpy(&shdrout.shdr[2], sec_strndx, sizeof(shdrout.shdr[2])); -- shdrout.shdr[2].sh_name = 20; -- shdrout.shdr[2].sh_size = 29; //size of our static shstrtab -+ set_te32(&shdrout.shdr[2].sh_name, 20); -+ set_te32(&shdrout.shdr[2].sh_size, 29); //size of our static shstrtab - } - } - } -@@ -3790,26 +3797,33 @@ void PackLinuxElf64::pack1(OutputFile *fo, Filter & /*ft*/) - if (opt->o_unix.preserve_build_id) { - // set this so we can use elf_find_section_name - e_shnum = get_te16(&ehdri.e_shnum); -+ MemBuffer mb_shdri; - if (!shdri) { -- shdri = (Elf64_Shdr *)&file_image[get_te32(&ehdri.e_shoff)]; -+ mb_shdri.alloc(e_shnum * sizeof(Elf64_Shdr)); -+ shdri = (Elf64_Shdr *)mb_shdri.getVoidPtr(); -+ e_shoff = get_te64(&ehdri.e_shoff); -+ fi->seek(e_shoff, SEEK_SET); -+ fi->readx(shdri, e_shnum * sizeof(Elf64_Shdr)); - } - //set the shstrtab - sec_strndx = &shdri[get_te16(&ehdri.e_shstrndx)]; - -- char *strtab = New(char, sec_strndx->sh_size); -+ upx_uint64_t sh_size = get_te64(&sec_strndx->sh_size); -+ char *strtab = New(char, sh_size); - fi->seek(0,SEEK_SET); - fi->seek(sec_strndx->sh_offset,SEEK_SET); -- fi->readx(strtab,sec_strndx->sh_size); -+ fi->readx(strtab, sh_size); - - shstrtab = (const char*)strtab; - - Elf64_Shdr const *buildid = elf_find_section_name(".note.gnu.build-id"); - if (buildid) { -- unsigned char *data = New(unsigned char, buildid->sh_size); -- memset(data,0,buildid->sh_size); -+ unsigned bid_sh_size = get_te32(&buildid->sh_size); -+ unsigned char *data = New(unsigned char, bid_sh_size); -+ memset(data,0,bid_sh_size); - fi->seek(0,SEEK_SET); - fi->seek(buildid->sh_offset,SEEK_SET); -- fi->readx(data,buildid->sh_size); -+ fi->readx(data,bid_sh_size); - - buildid_data = data; - -@@ -3818,12 +3832,12 @@ void PackLinuxElf64::pack1(OutputFile *fo, Filter & /*ft*/) - - //setup the build-id - memcpy(&shdrout.shdr[1], buildid, sizeof(shdrout.shdr[1])); -- shdrout.shdr[1].sh_name = 1; -+ set_te32(&shdrout.shdr[1].sh_name, 1); - - //setup the shstrtab - memcpy(&shdrout.shdr[2], sec_strndx, sizeof(shdrout.shdr[2])); -- shdrout.shdr[2].sh_name = 20; -- shdrout.shdr[2].sh_size = 29; //size of our static shstrtab -+ set_te32(&shdrout.shdr[2].sh_name, 20); -+ set_te32(&shdrout.shdr[2].sh_size, 29); //size of our static shstrtab - } - } - } diff --git a/sources b/sources index 96ff364..199bb43 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ -SHA512 (upx-3.96-src.tar.xz) = 2d4d1be21d274d9bfdee9b9815396f5e5ff0bcdfb781b7be5fafa4d1e224028e412ec5f5ba607c482671aae27ccf9069abb2db0fb58f78f3a102a51897df2b11 -SHA512 (upx-lzma-sdk-3.96.tar.gz) = 9690a1dfabf8bcb161b26761556a390aa354b633914254b29e36246fe11f9c3e905dafa916d0d52300bd418e2bddedd4122027e447fc87183bce4479e771c7df +SHA512 (upx-4.0.0-src.tar.xz) = fe3e8c594e845a91338b1e11fe3cb6371430af40a567187d63835e27da8b2abf993a104b0693063f4db984234bada7b2bd16ad79e3ad90861a1f495d99de7de6 diff --git a/upx-nohtml.patch b/upx-nohtml.patch deleted file mode 100644 index b50f935..0000000 --- a/upx-nohtml.patch +++ /dev/null @@ -1,52 +0,0 @@ -*** doc/Makefile~ 2018-08-25 21:58:09.000000000 -0500 ---- doc/Makefile 2018-08-27 10:24:23.304422432 -0500 -*************** -*** 26,33 **** - RTRIM := sed -e 's/[ $(tab)]*$$//' - DETAB2 := sed -e 's/$(tab)/ /g' - -! BUILT_SOURCES = upx.1 upx.doc upx.html upx.man upx.ps upx.tex -! BUILT_SOURCES = upx.1 upx.doc upx.html - - - ### ---- 26,33 ---- - RTRIM := sed -e 's/[ $(tab)]*$$//' - DETAB2 := sed -e 's/$(tab)/ /g' - -! BUILT_SOURCES = upx.1 upx.doc upx.man upx.ps upx.tex -! BUILT_SOURCES = upx.1 upx.doc - - - ### -*************** -*** 46,52 **** - ### rules - ### - -! .SUFFIXES: .1 .doc .html .man .pod .ps .tex - - %.1 : %.pod - pod2man --center=" " --release="$(PACKAGE) $(VERSION)" --date="$(VERSION_DATE)" $< | $(RTRIM) > $@ ---- 46,52 ---- - ### rules - ### - -! .SUFFIXES: .1 .doc .man .pod .ps .tex - - %.1 : %.pod - pod2man --center=" " --release="$(PACKAGE) $(VERSION)" --date="$(VERSION_DATE)" $< | $(RTRIM) > $@ -*************** -*** 56,66 **** - pod2text < $< | $(RTRIM) > $@ - test -s $@ - -- %.html : %.pod -- pod2html --noindex $< | $(RTRIM) | $(DETAB2) > $@ -- @rm -f pod2htm* -- test -s $@ -- - %.man : %.1 - nroff -man $< | $(RTRIM) > $@ - test -s $@ ---- 56,61 ---- diff --git a/upx-whitespace.patch b/upx-whitespace.patch deleted file mode 100644 index 9657b2b..0000000 --- a/upx-whitespace.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- src/Makefile~ 2017-01-29 10:53:00.000000000 -0600 -+++ src/Makefile 2017-03-30 10:03:12.447172055 -0500 -@@ -86,7 +86,7 @@ - $($(notdir $@).PRE_LINK_STEP) - $(strip $(CXXLD) $(call ee,CXXFLAGS) $(call ee,LDFLAGS) -o $@ $(upx_OBJECTS) $(call ee,LDADD) $(call ee,LIBS)) - $($(notdir $@).POST_LINK_STEP) -- $(CHECK_WHITESPACE) -+# $(CHECK_WHITESPACE) - - %.o : %.cpp | ./.depend - $(strip $(CXX) $(call ee,CPPFLAGS) $(call ee,CXXFLAGS) -o $@ -c $<) diff --git a/upx.spec b/upx.spec index b263122..946d93f 100644 --- a/upx.spec +++ b/upx.spec @@ -1,21 +1,15 @@ Name: upx -Version: 3.96 -Release: 12%{?dist} +Version: 4.0.0 +Release: 1%{?dist} Summary: Ultimate Packer for eXecutables License: GPLv2+ and Public Domain -URL: http://upx.sourceforge.net/ -Source0: http://upx.sourceforge.net/download/%{name}-%{version}-src.tar.xz -Source1: https://github.com/upx/upx-lzma-sdk/archive/v%{version}/upx-lzma-sdk-%{version}.tar.gz -Patch0: upx-whitespace.patch -Patch1: upx-nohtml.patch -Patch2: dadfd43ecb9909b0fab18e77753953a91322c628.patch -Patch3: 2fcaa16c13eda34307ccceea2263e474c54ee075.patch -Patch4: 3781df9da23840e596d5e9e8493f22666802fe6c.patch -Patch5: 87b73e5cfdc12da94c251b2cd83bb01c7d9f616c.patch - -BuildRequires: make +URL: https://github.com/upx/upx +Source0: %{url}/releases/download/v%{version}/%{name}-%{version}-src.tar.xz + +BuildRequires: make BuildRequires: gcc-c++ +BuildRequires: cmake BuildRequires: ucl-devel >= 1.01 BuildRequires: zlib-devel BuildRequires: perl-podlators @@ -29,39 +23,28 @@ executables suffer no memory overhead or other drawbacks. %prep %setup -qn %{name}-%{version}-src -sed -i -e 's/ -O2/ /' -e 's/ -Werror//' src/Makefile - -tar xfz %{SOURCE1} --strip-components=1 -C src/lzma-sdk/ - -%patch0 -p0 -%patch1 -p0 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 %build -export CXX="g++" -export CXXFLAGS="$RPM_OPT_FLAGS" # export, not to make so it won't trump all -export UPX_LUADIR=/usr/include -export UPX_UCLDIR=/usr/include/ucl -make %{?_smp_mflags} -C src -make -C doc +%cmake +%cmake_build %install -install -Dpm 644 doc/upx.1 $RPM_BUILD_ROOT%{_mandir}/man1/upx.1 -install -Dpm 755 src/upx.out $RPM_BUILD_ROOT%{_bindir}/upx - +%cmake_install +mv %{buildroot}%{_datadir}/doc/upx/upx-doc.* . +rm -f %{buildroot}%{_datadir}/doc/upx/* %files %license COPYING LICENSE -%doc BUGS NEWS PROJECTS README README.1ST THANKS +%doc NEWS README README.SRC THANKS upx-doc.* %{_bindir}/upx %{_mandir}/man1/upx.1* %changelog +* Fri Nov 04 2022 Gwyn Ciesla - 4.0.0-1 +- 4.0.0 + * Sat Jul 23 2022 Fedora Release Engineering - 3.96-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild