[mc] fix crash while copying files to directory with '?' letters in its name (#576622)
Jindrich Novy
jnovy at fedoraproject.org
Thu Sep 2 15:23:58 UTC 2010
commit b2df7e77bf95e266a2b4bb1f29007f2b7eaa8462
Author: Jindrich Novy <jnovy at redhat.com>
Date: Thu Sep 2 17:23:52 2010 +0200
fix crash while copying files to directory with '?' letters in its name (#576622)
mc-dirname.patch | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
mc.spec | 4 ++
2 files changed, 86 insertions(+), 0 deletions(-)
---
diff --git a/mc-dirname.patch b/mc-dirname.patch
new file mode 100644
index 0000000..19ee93d
--- /dev/null
+++ b/mc-dirname.patch
@@ -0,0 +1,82 @@
+diff -up mc-4.7.3/lib/search/glob.c.dirname mc-4.7.3/lib/search/glob.c
+--- mc-4.7.3/lib/search/glob.c.dirname 2010-07-05 20:32:41.000000000 +0200
++++ mc-4.7.3/lib/search/glob.c 2010-09-02 17:21:07.174555656 +0200
+@@ -118,14 +118,25 @@ mc_search__translate_replace_glob_to_reg
+ {
+ GString *buff = g_string_new ("");
+ int cnt = '0';
+-
++ gboolean escaped_mode = FALSE;
+ while (*str) {
+ char c = *str++;
+ switch (c) {
++ case '\\':
++ if (!escaped_mode)
++ {
++ escaped_mode = TRUE;
++ }
++ g_string_append_c (buff, c);
++ continue;
+ case '*':
+ case '?':
++ if (!escaped_mode)
++ {
+ g_string_append_c (buff, '\\');
+ c = ++cnt;
++ continue;
++ }
+ break;
+ /* breaks copying: mc uses "\0" internally, it must not be changed */
+ /*case '\\':*/
+@@ -134,6 +145,7 @@ mc_search__translate_replace_glob_to_reg
+ break;
+ }
+ g_string_append_c (buff, c);
++ escaped_mode = FALSE;
+ }
+ return buff;
+ }
+@@ -170,7 +182,6 @@ mc_search__run_glob (mc_search_t * lc_mc
+
+ /* --------------------------------------------------------------------------------------------- */
+
+-
+ GString *
+ mc_search_glob_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str)
+ {
+diff -up mc-4.7.3/lib/search/regex.c.dirname mc-4.7.3/lib/search/regex.c
+--- mc-4.7.3/lib/search/regex.c.dirname 2010-07-05 20:32:41.000000000 +0200
++++ mc-4.7.3/lib/search/regex.c 2010-09-02 17:19:26.836553568 +0200
+@@ -320,7 +320,7 @@ mc_search_regex__get_max_num_of_replace_
+ gsize loop;
+ for (loop = 0; loop < len - 1; loop++)
+ {
+- if (str[loop] == '\\' && (str[loop + 1] & (char) 0xf0) == 0x30 /* 0-9 */ )
++ if (str[loop] == '\\' && g_ascii_isdigit(str[loop + 1]) )
+ {
+ if (strutils_is_char_escaped (str, &str[loop]))
+ continue;
+@@ -421,9 +421,9 @@ mc_search_regex__process_replace_str (co
+ return -1;
+ }
+
+- if ((*(curr_str + 1) & (char) 0xf0) == 0x30)
++ if ( g_ascii_isdigit(*(curr_str + 1)))
+ {
+- ret = *(curr_str + 1) - '0';
++ ret = g_ascii_digit_value (*(curr_str + 1));
+ *skip_len = 2; /* \\ and one digit */
+ return ret;
+ }
+diff -up mc-4.7.3/lib/strutil/strescape.c.dirname mc-4.7.3/lib/strutil/strescape.c
+--- mc-4.7.3/lib/strutil/strescape.c.dirname 2010-07-05 20:32:41.000000000 +0200
++++ mc-4.7.3/lib/strutil/strescape.c 2010-09-02 17:19:26.835554197 +0200
+@@ -39,7 +39,7 @@
+
+ static const char ESCAPE_SHELL_CHARS[] = " !#$%()&{}[]`?|<>;*\\\"'";
+ static const char ESCAPE_REGEX_CHARS[] = "^!#$%()&{}[]`?|<>;*.\\";
+-static const char ESCAPE_GLOB_CHARS[] = "$*\\";
++static const char ESCAPE_GLOB_CHARS[] = "$*\\?";
+
+ /*** file scope functions ************************************************************************/
+
diff --git a/mc.spec b/mc.spec
index a55da11..43b2c3d 100644
--- a/mc.spec
+++ b/mc.spec
@@ -16,6 +16,7 @@ Patch0: mc-extensions.patch
Patch1: mc-mcviewsegfault.patch
Patch2: mc-achownsegfault.patch
Patch3: mc-dircopying.patch
+Patch4: mc-dirname.patch
%description
Midnight Commander is a visual shell much like a file manager, only
@@ -30,6 +31,7 @@ specific files.
%patch1 -p1 -b .mcviewsegfault
%patch2 -p1 -b .achownsegfault
%patch3 -p1 -b .dircopying
+%patch4 -p1 -b .dirname
%build
export CFLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $RPM_OPT_FLAGS"
@@ -93,6 +95,8 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Thu Sep 2 2010 Jindrich Novy <jnovy at redhat.com> 4.7.3-3
- fix broken directory copying, backport from upstream (#624973)
+- backport patch fixing crash while copying files to directory
+ with '?' letters in its name (#576622)
* Wed Sep 1 2010 Jindrich Novy <jnovy at redhat.com> 4.7.3-2
- fix segfault in advanced chown dialog (#625801)
More information about the scm-commits
mailing list