Open
fix: NUL terminate CDF directory name #95
liu-haodong142Add on 4 days ago
fix: NUL terminate CDF directory name #95
Open
Total: 2 files changed+42-1
| @@ -0,0 +1,36 @@ | |||
| 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 | +@@ -397,7 +397,7 @@ cdf_check_summary_info(struct magic_set *ms, const cdf_info_t *info, | ||
| 18 | + int i; | ||
| 19 | + const char *str = NULL; | ||
| 20 | + cdf_directory_t *d; | ||
| 21 | +- char name[__arraycount(d->d_name)]; | ||
| 22 | ++ char name[__arraycount(d->d_name) + 1]; | ||
| 23 | + size_t j, k; | ||
| 24 | + | ||
| 25 | + #ifdef CDF_DEBUG | ||
| 26 | +@@ -411,8 +411,9 @@ cdf_check_summary_info(struct magic_set *ms, const cdf_info_t *info, | ||
| 27 | + return i; | ||
| 28 | + for (j = 0; str == NULL && j < dir->dir_len; j++) { | ||
| 29 | + d = &dir->dir_tab[j]; | ||
| 30 | +- for (k = 0; k < sizeof(name); k++) | ||
| 31 | ++ for (k = 0; k < sizeof(name) - 1; k++) | ||
| 32 | + name[k] = CAST(char, cdf_tole2(d->d_name[k])); | ||
| 33 | ++ name[sizeof(name) - 1] = '\0'; | ||
| 34 | + str = cdf_app_to_mime(name, | ||
| 35 | + NOTMIME(ms) ? name2desc : name2mime); | ||
| 36 | + } | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | Name: file | 1 | Name: file |
| 2 | Version: 5.41 | 2 | Version: 5.41 |
| 3 | -Release: 7 | 3 | +Release: 8 |
| 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/ |
| @@ -11,6 +11,7 @@ Patch2: 0002-fix-typos-fxlb.patch | |||
| 11 | Patch3: CVE-2022-48554.patch | 11 | Patch3: CVE-2022-48554.patch |
| 12 | Patch4: 0003-Avoid-leak-in-zlib-clusterfuzz.patch | 12 | Patch4: 0003-Avoid-leak-in-zlib-clusterfuzz.patch |
| 13 | Patch5: 0004-Prevent-incorrect-result-for-nbytes-2GB.patch | 13 | Patch5: 0004-Prevent-incorrect-result-for-nbytes-2GB.patch |
| 14 | +Patch6: backport-cdf-name-nul-terminate.patch | ||
| 14 | 15 | ||
| 15 | Requires: %{name}-libs = %{version}-%{release} | 16 | Requires: %{name}-libs = %{version}-%{release} |
| 16 | BuildRequires: autoconf automake libtool zlib-devel make | 17 | BuildRequires: autoconf automake libtool zlib-devel make |
| @@ -137,6 +138,10 @@ make -C tests check | |||
| 137 | %{python3_sitelib}/__pycache__/* | 138 | %{python3_sitelib}/__pycache__/* |
| 138 | 139 | ||
| 139 | %changelog | 140 | %changelog |
| 141 | + | ||
| 142 | +* Tue Nov 03 2026 liu-haodong142 <dev03108@linx-info.com> - 5.41-8 | ||
| 143 | +- NUL terminate CDF directory name | ||
| 144 | + | ||
| 140 | * Thu Jul 16 2026 cenhuilin <cenhuilin@kylinos.cn> - 5.41-7 | 145 | * Thu Jul 16 2026 cenhuilin <cenhuilin@kylinos.cn> - 5.41-7 |
| 141 | - Prevent incorrect result for nbytes > 2GB | 146 | - Prevent incorrect result for nbytes > 2GB |
| 142 | 147 | ||