Segfault when viewing HTML files with "mc -v"



(I'm on Linux 64-bit. This happens with current Git master as well as the 4.8.4 release. 4.8.3 does not have the issue. I could not bisect the commit causing this because somewhere along the way, viewing HTML files is not possible at all.)

When viewing HTML files with "mc -v" (or "mcview"), a segfault occurs. Call stack:

  name_quote (lib/util.c:256)
  expand_format (src/filemanager/usermenu.c:863)
  regex_command (src/filemanager/ext.c:177)
  view_file_at_line (src/filemanager/cmd.c:647)
  do_nc (src/filemanager/midnight.c:1006)
  main (src/main.c:567)

In name_quote(), 's' is NULL and thus a segfault occurs when dereferencing it. Quick fix below. The proper fix is probably to avoid the whole thing in expand_format().


diff --git a/lib/util.c b/lib/util.c
index a56e2c8..52610a4 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -253,6 +253,11 @@ name_quote (const char *s, int quote_percent)
 {
     char *ret, *d;

+    if (s == NULL)
+    {
+        return NULL;
+    }
+
     d = ret = g_malloc (strlen (s) * 2 + 2 + 1);
     if (*s == '-')
     {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]