public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Peter Lemenkov <lemenkov@gmail.com>
To: git-commits@fedoraproject.org
Subject: [rpms/unshield] f43: Validate the file table against the header size
Date: Sun, 18 Oct 2026 16:04:10 GMT [thread overview]
Message-ID: <179233945047.1.2408591355059543291.rpms-unshield-f76ee6f6981c@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/unshield
Branch : f43
Commit : f76ee6f6981c203ca3f5cd7908cde912f363ca37
Author : Peter Lemenkov <lemenkov@gmail.com>
Date : 2026-10-18T17:28:59+02:00
Stats : +72/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/unshield/c/f76ee6f6981c203ca3f5cd7908cde912f363ca37?branch=f43
Log:
Validate the file table against the header size
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
diff --git a/0001-Validate-the-file-table-against-the-header-size.patch b/0001-Validate-the-file-table-against-the-header-size.patch
new file mode 100644
index 0000000..ea206b6
--- /dev/null
+++ b/0001-Validate-the-file-table-against-the-header-size.patch
@@ -0,0 +1,70 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Sun, 18 Oct 2026 17:05:00 +0200
+Subject: [PATCH] Validate the file table against the header size
+
+unshield_get_file_table() took the cabinet descriptor offset, the file
+table offset and the directory/file counts directly from the cabinet
+file and then read (directory_count + file_count) 32-bit words starting
+at data + cab_descriptor_offset + file_table_offset, without checking
+that this range stays within the header buffer. A cabinet with an
+out-of-range offset or an oversized file or directory count makes the
+loop read past the end of the allocated buffer.
+
+Compute the start offset and the number of bytes the loop will read in
+64-bit arithmetic so the additions cannot wrap, reject an empty table,
+and reject any table that would start past the buffer or extend beyond
+it before reading. The allocation result is now checked as well.
+
+Reported-by: haind-pwn (VulnCheck)
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/lib/libunshield.c b/lib/libunshield.c
+index 7b8edf2..c98fed9 100644
+--- a/lib/libunshield.c
++++ b/lib/libunshield.c
+@@ -182,13 +182,37 @@ static bool unshield_get_cab_descriptor(Header* header)
+
+ static bool unshield_get_file_table(Header* header)
+ {
+- uint8_t* p = header->data +
+- header->common.cab_descriptor_offset +
+- header->cab.file_table_offset;
+- int count = header->cab.directory_count + header->cab.file_count;
+- int i;
+-
++ uint64_t start = (uint64_t)header->common.cab_descriptor_offset +
++ (uint64_t)header->cab.file_table_offset;
++ uint64_t count = (uint64_t)header->cab.directory_count +
++ (uint64_t)header->cab.file_count;
++ uint64_t bytes = count * (uint64_t)sizeof(uint32_t);
++ uint8_t* p;
++ uint64_t i;
++
++ if (count == 0)
++ {
++ unshield_error("File table is empty");
++ return false;
++ }
++
++ if (start > header->size || bytes > (uint64_t)header->size - start)
++ {
++ unshield_error("File table (offset %lu, %lu bytes) is out of bounds "
++ "for header of %lu bytes",
++ (unsigned long)start, (unsigned long)bytes,
++ (unsigned long)header->size);
++ return false;
++ }
++
++ p = header->data + start;
++
+ header->file_table = calloc(count, sizeof(uint32_t));
++ if (!header->file_table)
++ {
++ unshield_error("Failed to allocate file table");
++ return false;
++ }
+
+ for (i = 0; i < count; i++)
+ {
diff --git a/unshield.spec b/unshield.spec
index ab27f0c..4431f81 100644
--- a/unshield.spec
+++ b/unshield.spec
@@ -6,7 +6,8 @@ SourceLicense: MIT and LicenseRef-RSA
License: MIT
URL: https://github.com/twogood/unshield
VCS: git:%{url}.git
-Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
+Source: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
+Patch: 0001-Validate-the-file-table-against-the-header-size.patch
BuildRequires: gcc
BuildRequires: openssl-devel
BuildRequires: zlib-devel
reply other threads:[~2026-10-18 16:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179233945047.1.2408591355059543291.rpms-unshield-f76ee6f6981c@fedoraproject.org \
--to=lemenkov@gmail.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox