Remove the size limit check of the elf note section

Resolves: rhbz#2167964
This commit is contained in:
Vincent Mihalkovic 2023-03-01 14:24:22 +01:00 committed by vmihalko
parent f4e6172807
commit 9c4850b7c4
3 changed files with 31 additions and 28 deletions

View File

@ -0,0 +1,25 @@
diff --git a/src/readelf.c b/src/readelf.c
index 97d1451..f6e3bec 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -62,7 +62,6 @@ file_private uint64_t getu64(int, uint64_t);
#define MAX_PHNUM 128
#define MAX_SHNUM 32768
-#define MAX_SHSIZE (64 * 1024 * 1024)
#define SIZE_UNKNOWN CAST(off_t, -1)
file_private int
@@ -1453,12 +1452,6 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
return -1;
return 0;
}
- if (xsh_size > MAX_SHSIZE) {
- file_error(ms, errno, "Note section size too "
- "big (%ju > %u)", (uintmax_t)xsh_size,
- MAX_SHSIZE);
- return -1;
- }
if ((nbuf = malloc(xsh_size)) == NULL) {
file_error(ms, errno, "Cannot allocate memory"
" for note");

View File

@ -1,25 +0,0 @@
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: 2%{?dist}
Release: 3%{?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
@ -34,8 +34,8 @@ 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
# revert upstream commit: https://github.com/file/file/commit/e1233247bbe4d2d66b891224336a23384a93cce1
Patch4: file-5.44-readelf-limit-revert.patch
URL: https://www.darwinsys.com/file/
Requires: file-libs%{?_isa} = %{version}-%{release}
@ -221,6 +221,9 @@ make -C tests check
%endif
%changelog
* Wed Mar 01 2023 Vincent Mihalkovic <vmihalko@redhat.com> - 5.44-3
- Remove the size limit check of the elf note section (rhbz#2167964)
* 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!