[packages/mc] Rel 2. Fix %cd ext overflow, cpio symlink size, ls parse underflow.
arekm
arekm at pld-linux.org
Thu Oct 29 08:46:21 CET 2026
commit 480a7a22db1b41e4fd06174475db78ce779f0730
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Oct 29 01:27:46 2026 +0100
Rel 2. Fix %cd ext overflow, cpio symlink size, ls parse underflow.
mc-cpio-symlink-size.patch | 34 +++++++++++
mc-ext-cd-overflow.patch | 129 ++++++++++++++++++++++++++++++++++++++++
mc-parse-ls-eol-underflow.patch | 74 +++++++++++++++++++++++
mc.spec | 18 +++---
4 files changed, 247 insertions(+), 8 deletions(-)
---
diff --git a/mc.spec b/mc.spec
index ddbf7f7..ba909ab 100644
--- a/mc.spec
+++ b/mc.spec
@@ -18,7 +18,7 @@ Summary(uk.UTF-8): Диспетчер файлів Midnight Commander
Summary(zh_CN.UTF-8): 一个方便实用的文件管理器和虚拟Shell
Name: mc
Version: 4.8.33
-Release: 1
+Release: 2
Epoch: 1
License: GPL v3+
Group: Applications/Shells
@@ -34,20 +34,21 @@ Patch3: %{name}-noperl-vfs.patch
Patch4: %{name}-pld-developerfriendly.patch
Patch5: ebook-ext.patch
Patch6: typescript-ext.patch
+Patch7: %{name}-cpio-symlink-size.patch
+Patch8: %{name}-parse-ls-eol-underflow.patch
+Patch9: %{name}-ext-cd-overflow.patch
URL: http://www.midnight-commander.org/
BuildRequires: autoconf >= 2.64
BuildRequires: automake >= 1:1.14
-%{?with_ext2undel:BuildRequires: e2fsprogs-devel}
+BuildRequires: e2fsprogs-devel >= 1.42.4
BuildRequires: file
BuildRequires: gettext-tools >= 0.21
-BuildRequires: glib2-devel >= 1:2.30.0
+BuildRequires: glib2-devel >= 1:2.32.0
%ifnarch s390 s390x
BuildRequires: gpm-devel
%endif
BuildRequires: libssh2-devel >= 1.2.8
BuildRequires: libtool >= 2:2
-BuildRequires: pam-devel
-BuildRequires: pcre-devel
BuildRequires: pkgconfig
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 1.268
@@ -57,9 +58,8 @@ BuildRequires: tar >= 1:1.22
%{?with_x:BuildRequires: xorg-lib-libX11-devel}
BuildRequires: xz
Requires: file
-Requires: glib2 >= 1:2.30.0
+Requires: glib2 >= 1:2.32.0
Requires: libssh2 >= 1.2.8
-Requires: pam >= 0.77.3
Requires: sed
Requires: setup >= 2.4.6-2
Suggests: bzip2
@@ -168,6 +168,9 @@ tar, zip ve RPM dosyalarının içeriklerini gösterebilmesidir.
%patch -P4 -p1
%patch -P5 -p1
%patch -P6 -p1
+%patch -P7 -p1
+%patch -P8 -p1
+%patch -P9 -p1
%{__rm} po/stamp-po
@@ -187,7 +190,6 @@ export X11_WWW="xdg-open"
%{?with_ext2undel:--enable-vfs-undelfs} \
--with%{!?with_x:out}-x \
--with-gpm-mouse \
- --with-pcre \
--with-screen=slang \
--disable-silent-rules
diff --git a/mc-cpio-symlink-size.patch b/mc-cpio-symlink-size.patch
new file mode 100644
index 0000000..9f56678
--- /dev/null
+++ b/mc-cpio-symlink-size.patch
@@ -0,0 +1,34 @@
+Reject cpio symlinks with absurd target sizes: 8 GiB aborts g_malloc(), with 32-bit
+size_t the size wraps to g_malloc(0) and the read overflows the heap.
+https://github.com/MidnightCommander/mc/commit/8196e5bec454c93aa183e38df34c9db590684602
+
+diff --git a/src/vfs/cpio/cpio.c b/src/vfs/cpio/cpio.c
+index 93653d8..3ca7261 100644
+--- a/src/vfs/cpio/cpio.c
++++ b/src/vfs/cpio/cpio.c
+@@ -380,6 +380,15 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, struct stat
+ struct vfs_s_entry *entry = NULL;
+ char *tn;
+
++ /* the link target is read into memory as a whole below, so reject absurd lengths up front,
++ before the entry or the inode of a hardlink gets touched */
++ if (S_ISLNK (st->st_mode) && (st->st_size < 0 || st->st_size > MC_MAXPATHLEN))
++ {
++ message (D_ERROR, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"), super->name);
++ g_free (name);
++ return STATUS_FAIL;
++ }
++
+ switch (st->st_mode & S_IFMT)
+ { /* For case of HP/UX archives */
+ case S_IFCHR:
+@@ -518,7 +527,8 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, struct stat
+ {
+ /* FIXME: do we must read from arch->fd in case of inode != NULL only or in any case? */
+
+- inode->linkname = g_malloc (st->st_size + 1);
++ /* the inode of a hardlink may already have the target from an earlier entry */
++ inode->linkname = g_realloc (inode->linkname, (gsize) st->st_size + 1);
+
+ if (mc_read (arch->fd, inode->linkname, st->st_size) < st->st_size)
+ {
diff --git a/mc-ext-cd-overflow.patch b/mc-ext-cd-overflow.patch
new file mode 100644
index 0000000..335dd47
--- /dev/null
+++ b/mc-ext-cd-overflow.patch
@@ -0,0 +1,129 @@
+%cd in mc.ext.ini expands names into a static 1 KiB buffer without bounds checks (#5115).
+https://github.com/MidnightCommander/mc/commit/694c66817ae106e3cadf8f3c22e9fea6530df93b
+
+diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c
+index e676cb9..9748e9b 100644
+--- a/src/filemanager/ext.c
++++ b/src/filemanager/ext.c
+@@ -96,9 +96,7 @@ typedef char *(*quote_func_t) (const char *name, gboolean quote_percent);
+ static mc_config_t *ext_ini = NULL;
+ static gchar **ext_ini_groups = NULL;
+ static vfs_path_t *localfilecopy_vpath = NULL;
+-static char buffer[BUF_1K];
+
+-static char *pbuffer = NULL;
+ static time_t localmtime = 0;
+ static quote_func_t quote_func = name_quote;
+ static gboolean run_view = FALSE;
+@@ -235,7 +233,7 @@ exec_get_export_variables (const vfs_path_t *filename_vpath)
+ /* --------------------------------------------------------------------------------------------- */
+
+ static GString *
+-exec_make_shell_string (const char *lc_data, const vfs_path_t *filename_vpath)
++exec_make_shell_string (const char *lc_data, const vfs_path_t *filename_vpath, GString **buffer)
+ {
+ GString *shell_string;
+ char lc_prompt[80] = "\0";
+@@ -301,7 +299,12 @@ exec_make_shell_string (const char *lc_data, const vfs_path_t *filename_vpath)
+ is_cd = TRUE;
+ quote_func = fake_name_quote;
+ do_local_copy = FALSE;
+- pbuffer = buffer;
++
++ if (*buffer == NULL)
++ *buffer = g_string_sized_new (128);
++ else
++ g_string_set_size (*buffer, 0);
++
+ lc_data += i - 1;
+ }
+ else
+@@ -336,10 +339,7 @@ exec_make_shell_string (const char *lc_data, const vfs_path_t *filename_vpath)
+ if (!is_cd)
+ g_string_append (shell_string, text);
+ else
+- {
+- strcpy (pbuffer, text);
+- pbuffer = strchr (pbuffer, '\0');
+- }
++ g_string_append (*buffer, text);
+
+ g_free (text);
+ }
+@@ -357,7 +357,7 @@ exec_make_shell_string (const char *lc_data, const vfs_path_t *filename_vpath)
+ if (!whitespace (*lc_data))
+ written_nonspace = TRUE;
+ if (is_cd)
+- *(pbuffer++) = *lc_data;
++ g_string_append_c (*buffer, *lc_data);
+ else
+ g_string_append_c (shell_string, *lc_data);
+ }
+@@ -406,21 +406,18 @@ exec_extension_view (void *target, char *cmd, const vfs_path_t *filename_vpath,
+ /* --------------------------------------------------------------------------------------------- */
+
+ static void
+-exec_extension_cd (WPanel *panel)
++exec_extension_cd (WPanel *panel, GString *buffer)
+ {
+- char *q;
++ size_t i;
+ vfs_path_t *p_vpath;
+
+- *pbuffer = '\0';
+- pbuffer = buffer;
+ /* Search last non-space character. Start search at the end in order
+ not to short filenames containing spaces. */
+- q = pbuffer + strlen (pbuffer) - 1;
+- while (q >= pbuffer && whitespace (*q))
+- q--;
+- q[1] = 0;
++ for (i = buffer->len; i != 0 && whitespace (buffer->str[i - 1]); i--)
++ ;
++ g_string_set_size (buffer, i);
+
+- p_vpath = vfs_path_from_str_flags (pbuffer, VPF_NO_CANON);
++ p_vpath = vfs_path_from_str_flags (buffer->str, VPF_NO_CANON);
+ panel_cd (panel, p_vpath, cd_parse_command);
+ vfs_path_free (p_vpath, TRUE);
+ }
+@@ -433,12 +430,12 @@ exec_extension (WPanel *panel, void *target, const vfs_path_t *filename_vpath,
+ const char *lc_data, int start_line)
+ {
+ GString *shell_string, *export_variables;
++ GString *buffer = NULL;
+ vfs_path_t *script_vpath = NULL;
+ int cmd_file_fd;
+ FILE *cmd_file;
+ char *cmd = NULL;
+
+- pbuffer = NULL;
+ localmtime = 0;
+ quote_func = name_quote;
+ run_view = FALSE;
+@@ -448,13 +445,13 @@ exec_extension (WPanel *panel, void *target, const vfs_path_t *filename_vpath,
+ /* Avoid making a local copy if we are doing a cd */
+ do_local_copy = !vfs_file_is_local (filename_vpath);
+
+- shell_string = exec_make_shell_string (lc_data, filename_vpath);
++ shell_string = exec_make_shell_string (lc_data, filename_vpath, &buffer);
+ if (shell_string == NULL)
+ goto ret;
+
+ if (is_cd)
+ {
+- exec_extension_cd (panel);
++ exec_extension_cd (panel, buffer);
+ g_string_free (shell_string, TRUE);
+ goto ret;
+ }
+@@ -539,6 +536,9 @@ exec_extension (WPanel *panel, void *target, const vfs_path_t *filename_vpath,
+
+ exec_cleanup_file_name (filename_vpath, TRUE);
+ ret:
++ if (buffer != NULL)
++ g_string_free (buffer, TRUE);
++
+ return script_vpath;
+ }
+
diff --git a/mc-parse-ls-eol-underflow.patch b/mc-parse-ls-eol-underflow.patch
new file mode 100644
index 0000000..99601ea
--- /dev/null
+++ b/mc-parse-ls-eol-underflow.patch
@@ -0,0 +1,74 @@
+EOL stripping in vfs_parse_ls_lga() reads (and may write) one byte before a 0 or 1 char name.
+https://github.com/MidnightCommander/mc/commit/ac9a81d9bd369fc6f571850b90a2f534dc03cc8e
+
+diff --git a/lib/strutil.h b/lib/strutil.h
+index 713f997..a7d3318 100644
+--- a/lib/strutil.h
++++ b/lib/strutil.h
+@@ -584,6 +584,8 @@ char *str_regex_unescape (const char *text);
+
+ gboolean str_is_char_escaped (const char *start, const char *current);
+
++void str_rstrip_eol (char *s);
++
+ /* --------------------------------------------------------------------------------------------- */
+ /*** inline functions ****************************************************************************/
+ /* --------------------------------------------------------------------------------------------- */
+diff --git a/lib/strutil/strutil.c b/lib/strutil/strutil.c
+index a86598c..7c43f2f 100644
+--- a/lib/strutil/strutil.c
++++ b/lib/strutil/strutil.c
+@@ -1015,3 +1015,23 @@ parse_integer (const char *str, gboolean *invalid)
+ }
+
+ /* --------------------------------------------------------------------------------------------- */
++
++/**
++ * Strips single right (trailing) EOL (\\r, \\n, or \\r\\n), NULL-safe
++ */
++void
++str_rstrip_eol (char *s)
++{
++ size_t len;
++
++ if (s == NULL || *s == '\0')
++ return;
++
++ len = strlen (s);
++ if (len >= 2 && s[len - 2] == '\r' && s[len - 1] == '\n') /* removes \r\n */
++ s[len - 2] = '\0';
++ else if (s[len - 1] == '\n' || s[len - 1] == '\r') /* removes \n or \r */
++ s[len - 1] = '\0';
++}
++
++/* --------------------------------------------------------------------------------------------- */
+diff --git a/lib/vfs/parse_ls_vga.c b/lib/vfs/parse_ls_vga.c
+index dd91b88..171e641 100644
+--- a/lib/vfs/parse_ls_vga.c
++++ b/lib/vfs/parse_ls_vga.c
+@@ -40,6 +40,7 @@
+ #include <stdlib.h>
+
+ #include "lib/global.h"
++#include "lib/strutil.h"
+ #include "lib/unixcompat.h" /* makedev */
+ #include "lib/widget.h" /* message() */
+
+@@ -853,16 +854,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, char **linknam
+ *linkname = NULL;
+ }
+
+- if (t != NULL)
+- {
+- size_t p2;
+-
+- p2 = strlen (t);
+- if (--p2 > 0 && (t[p2] == '\r' || t[p2] == '\n'))
+- t[p2] = '\0';
+- if (--p2 > 0 && (t[p2] == '\r' || t[p2] == '\n'))
+- t[p2] = '\0';
+- }
++ str_rstrip_eol (t);
+
+ g_free (p_copy);
+ return TRUE;
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/mc.git/commitdiff/480a7a22db1b41e4fd06174475db78ce779f0730
More information about the pld-cvs-commit
mailing list