can't open /tmp/mc-<username>/mcextXXXXXX if username contains '\'

4 views
Skip to first unread message

BmW

unread,
Dec 14, 2010, 5:51:20 AM12/14/10
to mc-bugs
Hello!

I found a bug that makes it impossible to use filters in MC when
username contains character '\'.
In ubuntu when it connect to windows AD username looks like "DOMAINNAME
\username", so it contains '\' and when i try to view .html (for
example) i got this error message:

/bin/sh: Can't open /tmp/mc-DOMAINNAMEusername/mcextQj6A7d

to reproduce this bug you can create user a\b, run mc by this user and
try to view .html file.

# useradd a\\b
# su - a\\b
$ mc

...

'\' character eaten by function popen in mcview_load_command_output.

sample patch for 4.7.0.6 (easy adopted for other versions)


--- 1/src/viewer/datasource.c<->2010-06-05 00:58:04.000000000 +0600
+++ 2/src/viewer/datasource.c<->2010-12-14 13:56:09.000000000 +0500
@@ -360,7 +360,7 @@
mcview_close_datasource (view);
.
open_error_pipe ();
- if ((fp = popen (command, "r")) == NULL)
+ if ((fp = popen (g_strescape (command,""), "r")) == NULL)
{
/* Avoid two messages. Message from stderr has priority. */
mcview_display (view);

andrew_b

unread,
Dec 14, 2010, 8:10:38 AM12/14/10
to mc-bugs
On 14 дек, 13:51, BmW <bazano...@gmail.com> wrote:
> -    if ((fp = popen (command, "r")) == NULL)
> +    if ((fp = popen (g_strescape (command,""), "r")) == NULL)

Now the memory leak here. g_strescape() returns the newly-allocated
string.

--
Andrew

BmW

unread,
Dec 15, 2010, 3:19:54 AM12/15/10
to mc-bugs
Sorry, i have mad skilz in C++. Is it right way - create another const
char* and g_free it at the end of the function?

BmW

unread,
Dec 15, 2010, 3:20:58 AM12/15/10
to mc-bugs
Sorry, i have mad skilz in C++. Is it right way - create another const
char* and g_free it at the end of the function?


On 14 дек, 18:10, andrew_b <andrew.boro...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages