From 973bbb70a21e27d265b99fc89e9e11e531e5e6c3 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 7 Jul 2010 14:01:15 +0300 Subject: [PATCH] Ticket #2123: crash while copying into directory named "????" 1. create directory named "????" and enter into this directory 2. point at any file in other panel 3. press F5 and Enter Segfault Signed-off-by: Slava Zanko --- lib/search/glob.c | 14 +++++++++++++- lib/strutil/strescape.c | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/search/glob.c b/lib/search/glob.c index 154a9ca37..b3baa6901 100644 --- a/lib/search/glob.c +++ b/lib/search/glob.c @@ -118,14 +118,25 @@ mc_search__translate_replace_glob_to_regex (gchar *str) { 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; + continue; + } + break; 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_regex (gchar *str) break; } g_string_append_c (buff, c); + escaped_mode = FALSE; } return buff; } diff --git a/lib/strutil/strescape.c b/lib/strutil/strescape.c index 45b1946a7..76e562fb5 100644 --- a/lib/strutil/strescape.c +++ b/lib/strutil/strescape.c @@ -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 ************************************************************************/