From 382877771cdbc62216f3b0aadfe5cc8941a3be6c Mon Sep 17 00:00:00 2001 From: Vincent Mihalkovic Date: Feb 09 2023 13:12:13 +0000 Subject: Fix the size limit of the elf note section tests: test written by lzaoral, thanks! Resolves: rhbz#2167964 --- diff --git a/file-5.44-readelf-limit.patch b/file-5.44-readelf-limit.patch new file mode 100644 index 0000000..16d9264 --- /dev/null +++ b/file-5.44-readelf-limit.patch @@ -0,0 +1,25 @@ +From ba70807a0dab752835293cc586e104b5dedd9c3f Mon Sep 17 00:00:00 2001 +From: Vincent Mihalkovic +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 + diff --git a/file.spec b/file.spec index 47d7650..7015277 100644 --- a/file.spec +++ b/file.spec @@ -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 - 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 - 5.44-1 - update to new version 5.44 diff --git a/tests/bz2167964-file-fails-on-binary-with-big-note-section/main.fmf b/tests/bz2167964-file-fails-on-binary-with-big-note-section/main.fmf new file mode 100644 index 0000000..c0f0901 --- /dev/null +++ b/tests/bz2167964-file-fails-on-binary-with-big-note-section/main.fmf @@ -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 diff --git a/tests/bz2167964-file-fails-on-binary-with-big-note-section/runtest.sh b/tests/bz2167964-file-fails-on-binary-with-big-note-section/runtest.sh new file mode 100755 index 0000000..e475b1d --- /dev/null +++ b/tests/bz2167964-file-fails-on-binary-with-big-note-section/runtest.sh @@ -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