Open
file: backport upstream fix to NUL terminate CDF directory name #89
liu-haodong142Add on 9 days ago
file: backport upstream fix to NUL terminate CDF directory name #89
Open
Total: 2 files changed+51-1
| @@ -0,0 +1,45 @@ | |||
| 1 | +From 029e5bae7362e71671b3e1f316d4f3936d8a7819 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: Christos Zoulas <christos@zoulas.com> | ||
| 3 | +Date: Tue, 13 Oct 2026 15:54:12 +0000 | ||
| 4 | +Subject: [PATCH] PR/812: mgl: NUL terminate string passed to cdf_app_to_mime() | ||
| 5 | + | ||
| 6 | +(backported from commit 029e5bae7362e71671b3e1f316d4f3936d8a7819) | ||
| 7 | + | ||
| 8 | +Reference: https://github.com/file/file/commit/029e5bae7362e71671b3e1f316d4f3936d8a7819 | ||
| 9 | +--- | ||
| 10 | + src/readcdf.c | 7 ++++--- | ||
| 11 | + 1 file changed, 4 insertions(+), 3 deletions(-) | ||
| 12 | + | ||
| 13 | +diff --git a/src/readcdf.c b/src/readcdf.c | ||
| 14 | +index ab2984d7..49f4f844 100644 | ||
| 15 | +--- a/src/readcdf.c | ||
| 16 | ++++ b/src/readcdf.c | ||
| 17 | +@@ -26,7 +26,7 @@ | ||
| 18 | + #include "file.h" | ||
| 19 | + | ||
| 20 | + #ifndef lint | ||
| 21 | +-FILE_RCSID("@(#)$File: readcdf.c,v 1.82 2026/06/02 17:33:48 christos Exp $") | ||
| 22 | ++FILE_RCSID("@(#)$File: readcdf.c,v 1.83 2026/10/13 15:54:12 christos Exp $") | ||
| 23 | + #endif | ||
| 24 | + | ||
| 25 | + #include <assert.h> | ||
| 26 | +@@ -397,7 +397,7 @@ cdf_check_summary_info(struct magic_set *ms, const cdf_info_t *info, | ||
| 27 | + int i; | ||
| 28 | + const char *str = NULL; | ||
| 29 | + cdf_directory_t *d; | ||
| 30 | +- char name[__arraycount(d->d_name)]; | ||
| 31 | ++ char name[__arraycount(d->d_name) + 1]; | ||
| 32 | + size_t j, k; | ||
| 33 | + | ||
| 34 | + #ifdef CDF_DEBUG | ||
| 35 | +@@ -411,8 +411,9 @@ cdf_check_summary_info(struct magic_set *ms, const cdf_info_t *info, | ||
| 36 | + return i; | ||
| 37 | + for (j = 0; str == NULL && j < dir->dir_len; j++) { | ||
| 38 | + d = &dir->dir_tab[j]; | ||
| 39 | +- for (k = 0; k < sizeof(name); k++) | ||
| 40 | ++ for (k = 0; k < sizeof(name) - 1; k++) | ||
| 41 | + name[k] = CAST(char, cdf_tole2(d->d_name[k])); | ||
| 42 | ++ name[sizeof(name) - 1] = '\0'; | ||
| 43 | + str = cdf_app_to_mime(name, | ||
| 44 | + NOTMIME(ms) ? name2desc : name2mime); | ||
| 45 | + } | ||
| @@ -1,12 +1,13 @@ | |||
| 1 | Name: file | 1 | Name: file |
| 2 | Version: 5.48 | 2 | Version: 5.48 |
| 3 | -Release: 1 | 3 | +Release: 2 |
| 4 | Summary: A tool to identify the type of a particular file type | 4 | Summary: A tool to identify the type of a particular file type |
| 5 | License: BSD | 5 | License: BSD |
| 6 | URL: http://www.darwinsys.com/file/ | 6 | URL: http://www.darwinsys.com/file/ |
| 7 | Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz | 7 | Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz |
| 8 | 8 | ||
| 9 | Patch1: 0001-file-localmagic.patch | 9 | Patch1: 0001-file-localmagic.patch |
| 10 | +Patch2: backport-cdf-name-nul-terminate.patch | ||
| 10 | 11 | ||
| 11 | Requires: %{name}-libs = %{version}-%{release} | 12 | Requires: %{name}-libs = %{version}-%{release} |
| 12 | BuildRequires: autoconf automake libtool zlib-devel make | 13 | BuildRequires: autoconf automake libtool zlib-devel make |
| @@ -133,6 +134,10 @@ make -C tests check | |||
| 133 | %{python3_sitelib}/__pycache__/* | 134 | %{python3_sitelib}/__pycache__/* |
| 134 | 135 | ||
| 135 | %changelog | 136 | %changelog |
| 137 | +* Wed Oct 28 2026 liu-haodong142 <dev03108@linx-info.com> - 5.48-2 | ||
| 138 | +- Backport upstream fix to NUL terminate the CDF directory name passed to | ||
| 139 | + cdf_app_to_mime(), preventing a stack out-of-bounds read | ||
| 140 | + | ||
| 136 | * Wed Oct 14 2026 noodlesland <815543835@qq.com> - 5.48-1 | 141 | * Wed Oct 14 2026 noodlesland <815543835@qq.com> - 5.48-1 |
| 137 | - update to 5.48 | 142 | - update to 5.48 |
| 138 | 143 | ||