Compare commits

..

No commits in common. "rawhide" and "f31" have entirely different histories.

7 changed files with 241 additions and 130 deletions

16
.gitignore vendored
View file

@ -11,19 +11,3 @@ 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
/upx-4.0.1-src.tar.xz
/upx-4.0.2-src.tar.xz
/upx-4.1.0-src.tar.xz
/upx-4.2.0-src.tar.xz
/upx-4.2.1-src.tar.xz
/upx-4.2.2-src.tar.xz
/upx-4.2.3-src.tar.xz
/upx-4.2.4-src.tar.xz
/upx-5.0.0-src.tar.xz
/upx-5.0.1-src.tar.xz
/upx-5.0.2-src.tar.xz
/upx-5.1.0-src.tar.xz
/upx-5.1.1-src.tar.xz
/upx-5.2.0-src.tar.xz
/upx-5.2.1-src.tar.xz

View file

@ -0,0 +1,22 @@
From 2fcaa16c13eda34307ccceea2263e474c54ee075 Mon Sep 17 00:00:00 2001
From: Mattiwatti <mattiwatti@gmail.com>
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;

View file

@ -0,0 +1,127 @@
From dadfd43ecb9909b0fab18e77753953a91322c628 Mon Sep 17 00:00:00 2001
From: John Reiser <jreiser@BitWagon.com>
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
}
}
}

View file

@ -1 +1,2 @@
SHA512 (upx-5.2.1-src.tar.xz) = 38fa0aa9940d9518df5bf07725ed65391d1a965cac4feace190819e7bd8125e4ed23a3795cf0fb7d4df09fbca66158265ae5774a3c48f5b55e3905fc7b962bc4
SHA512 (upx-3.96-src.tar.xz) = 2d4d1be21d274d9bfdee9b9815396f5e5ff0bcdfb781b7be5fafa4d1e224028e412ec5f5ba607c482671aae27ccf9069abb2db0fb58f78f3a102a51897df2b11
SHA512 (upx-lzma-sdk-3.96.tar.gz) = 9690a1dfabf8bcb161b26761556a390aa354b633914254b29e36246fe11f9c3e905dafa916d0d52300bd418e2bddedd4122027e447fc87183bce4479e771c7df

52
upx-nohtml.patch Normal file
View file

@ -0,0 +1,52 @@
*** 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 ----

11
upx-whitespace.patch Normal file
View file

@ -0,0 +1,11 @@
--- 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 $<)

140
upx.spec
View file

@ -1,19 +1,21 @@
Name: upx
Version: 5.2.1
Release: 1%{?dist}
Version: 3.96
Release: 6%{?dist}
Summary: Ultimate Packer for eXecutables
License: GPL-2.0-or-later AND LicenseRef-Fedora-Public-Domain
URL: https://github.com/upx/upx
Source0: %{url}/releases/download/v%{version}/%{name}-%{version}-src.tar.xz
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
BuildRequires: make
BuildRequires: gcc-c++
BuildRequires: cmake
BuildRequires: ucl-devel >= 1.01
BuildRequires: zlib-devel
BuildRequires: perl-podlators
Provides: bundled(lzma-sdk) = 4.43
%description
UPX is a free, portable, extendable, high-performance executable
@ -24,125 +26,37 @@ 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
%build
%cmake
%cmake_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
%install
%cmake_install
mv %{buildroot}%{_datadir}/doc/upx/upx-doc.* .
rm -f %{buildroot}%{_datadir}/doc/upx/*
install -Dpm 644 doc/upx.1 $RPM_BUILD_ROOT%{_mandir}/man1/upx.1
install -Dpm 755 src/upx.out $RPM_BUILD_ROOT%{_bindir}/upx
%files
%license COPYING LICENSE
%doc NEWS README README.SRC doc/THANKS.txt upx-doc.*
%doc BUGS NEWS PROJECTS README README.1ST THANKS
%{_bindir}/upx
%{_mandir}/man1/upx.1*
%changelog
* Thu Aug 27 2026 Gwyn Ciesla <gwync@protonmail.com> - 5.2.1-1
- 5.2.1
* Fri Jul 17 2026 Fedora Release Engineering <releng@fedoraproject.org> - 5.2.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
* Thu Jun 11 2026 Gwyn Ciesla <gwync@protonmail.com> - 5.2.0-1
- 5.2.0
* Thu Mar 05 2026 Gwyn Ciesla <gwync@protonmail.com> - 5.1.1-1
- 5.1.1
* Sat Jan 17 2026 Fedora Release Engineering <releng@fedoraproject.org> - 5.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild
* Wed Jan 07 2026 Gwyn Ciesla <gwync@protonmail.com> - 5.1.0-1
- 5.1.0
* Fri Jul 25 2025 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
* Mon Jul 21 2025 Gwyn Ciesla <gwync@protonmail.com> - 5.0.2-1
- 5.0.2
* Tue May 06 2025 Gwyn Ciesla <gwync@protonmail.com> - 5.0.1-1
- 5.0.1
* Thu Feb 20 2025 Gwyn Ciesla <gwync@protonmail.com> - 5.0.0-1
- 5.0.0
* Sun Jan 19 2025 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
* Wed Dec 18 2024 Gwyn Ciesla <gwync@protonmail.com> - 4.2.4-3
- Provide bundled lzma-sdk
* Sat Jul 20 2024 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
* Tue May 21 2024 Gwyn Ciesla <gwync@protonmail.com> - 4.2.4-1
- 4.2.4
* Thu Mar 28 2024 Gwyn Ciesla <gwync@protonmail.com> - 4.2.3-1
- 4.2.3
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Thu Jan 04 2024 Gwyn Ciesla <gwync@protonmail.com> - 4.2.2-1
- 4.2.2
* Thu Nov 02 2023 Gwyn Ciesla <gwync@protonmail.com> - 4.2.1-1
- 4.2.1
* Fri Oct 27 2023 Gwyn Ciesla <gwync@protonmail.com> - 4.2.0-1
- 4.2.0
* Wed Aug 09 2023 Gwyn Ciesla <gwync@protonmail.com> - 4.1.0-1
- 4.1.0
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Sun Mar 05 2023 Gwyn Ciesla <gwync@protonmail.com> - 4.0.2-2
- migrated to SPDX license
* Wed Feb 01 2023 Gwyn Ciesla <gwync@protonmail.com> - 4.0.2-1
- 4.0.2
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Thu Jan 12 2023 Gwyn Ciesla <gwync@protonmail.com> - 4.0.1-2
- Patches for CVE-2023-23456, CVE-2023-23457
* Thu Nov 17 2022 Gwyn Ciesla <gwync@protonmail.com> - 4.0.1-1
- 4.0.1
* Fri Nov 04 2022 Gwyn Ciesla <gwync@protonmail.com> - 4.0.0-1
- 4.0.0
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.96-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.96-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.96-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Tue May 18 2021 Gwyn Ciesla <gwync@protonmail.com> - 3.96-9
- Patch for CVE-2020-24119
* Thu Mar 11 2021 Gwyn Ciesla <gwync@protonmail.com> - 3.96-8
- Patch for CVE-2021-20285
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.96-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Aug 10 2020 Gwyn Ciesla <gwync@protonmail.com> - 3.96-6
- Make PE load config directory address dword aligned