Fix the size limit of the elf note section

tests: test written by lzaoral, thanks!
Resolves: rhbz#2167964
This commit is contained in:
Vincent Mihalkovic 2023-02-09 13:47:04 +01:00
parent 02937e1761
commit 382877771c
4 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,25 @@
From ba70807a0dab752835293cc586e104b5dedd9c3f Mon Sep 17 00:00:00 2001
From: Vincent Mihalkovic <vmihalko@redhat.com>
Date: Thu, 9 Feb 2023 13:01:36 +0100
Subject: [PATCH] readelf: limit size of the note section to 128M
---
src/readelf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/readelf.c b/src/readelf.c
index 97d1451..ca158b1 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -62,7 +62,7 @@ file_private uint64_t getu64(int, uint64_t);
#define MAX_PHNUM 128
#define MAX_SHNUM 32768
-#define MAX_SHSIZE (64 * 1024 * 1024)
+#define MAX_SHSIZE (128 * 1024 * 1024)
#define SIZE_UNKNOWN CAST(off_t, -1)
file_private int
--
2.39.1

View File

@ -15,7 +15,7 @@
Summary: Utility for determining file types
Name: file
Version: 5.44
Release: 1%{?dist}
Release: 2%{?dist}
License: BSD
Source0: http://ftp.astron.com/pub/file/file-%{version}.tar.gz
Source1: http://ftp.astron.com/pub/file/file-%{version}.tar.gz.asc
@ -32,6 +32,9 @@ Patch2: file-5.04-volume_key.patch
# upstream commit: https://github.com/file/file/commit/1dd21dd360472d7b830825df8e40a06cdc1cbbcf
Patch3: file-5.44-compression.patch
# not yet in upstream
Patch4: file-5.44-readelf-limit.patch
URL: https://www.darwinsys.com/file/
Requires: file-libs%{?_isa} = %{version}-%{release}
BuildRequires: zlib-devel
@ -216,6 +219,10 @@ make -C tests check
%endif
%changelog
* Thu Feb 09 2023 Vincent Mihalkovic <vmihalko@redhat.com> - 5.44-2
- Fix the size limit of the elf note section (rhbz#2167964)
Test written by lzaoral, thanks!
* Fri Jan 20 2023 Vincent Mihalkovic <vmihalko@redhat.com> - 5.44-1
- update to new version 5.44

View File

@ -0,0 +1,11 @@
summary: bz2167964-file-fails-on-binary-with-big-note-section
component:
- file
test: ./runtest.sh
framework: beakerlib
recommend:
- binutils
- file
duration: 5m
extra-summary: /CoreOS/file/Regression/bz2167964-file-fails-on-binary-with-big-note-section
extra-task: /CoreOS/file/Regression/bz2167964-file-fails-on-binary-with-big-note-section

View File

@ -0,0 +1,25 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGES="file binutils"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "pushd \$tmp"
rlRun "set -o pipefail"
rlPhaseEnd
rlPhaseStartTest
rlRun "truncate --size=100M note" 0 "Create a dummy 100 MB file"
rlRun "objcopy --update-section .note.package=note /usr/bin/cp repro" \
0 "Create a copy of cp with large .note.package section"
rlRun "file repro" 0 "Run file of the reproducer"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r \$tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd