]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #16558 with w32-shell-execute on remote file names.
authorEli Zaretskii <eliz@gnu.org>
Sat, 1 Feb 2014 09:22:51 +0000 (11:22 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 1 Feb 2014 09:22:51 +0000 (11:22 +0200)
 src/w32fns.c (Fw32_shell_execute): Don't call file-exists-p for
 DOCUMENT that is a "remote" file name, i.e. a file-handler exists
 for it.

src/ChangeLog
src/w32fns.c

index ec17d7ace4f499738b42bd46a134c910821e1ea0..8a8956bec31c92cac9c7fc676872f0db1ab6ca29 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-01  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32fns.c (Fw32_shell_execute): Don't call file-exists-p for
+       DOCUMENT that is a "remote" file name, i.e. a file-handler exists
+       for it.  (Bug#16558)
+
 2014-01-30  Andreas Schwab  <schwab@linux-m68k.org>
 
        * process.c (create_process): Reset SIGPROF handler in the child.
index 98456cd20d4ee130470f17769dc254ca74c590a1..397b1796215af29fea8e3594e1c3a3f7f64676e9 100644 (file)
@@ -6892,7 +6892,8 @@ an integer representing a ShowWindow flag:
 #ifndef CYGWIN
   int use_unicode = w32_unicode_filenames;
   char *doc_a = NULL, *params_a = NULL, *ops_a = NULL;
-  Lisp_Object absdoc;
+  Lisp_Object absdoc, handler;
+  struct gcpro gcpro1;
 #endif
 
   CHECK_STRING (document);
@@ -6927,10 +6928,24 @@ an integer representing a ShowWindow flag:
      does not have to be a file, it can be a URL, for example.  So we
      make it absolute only if it is an existing file; if it is a file
      that does not exist, tough.  */
+  GCPRO1 (absdoc);
   absdoc = Fexpand_file_name (document, Qnil);
-  if (!NILP (Ffile_exists_p (absdoc)))
-    document = absdoc;
-  document = ENCODE_FILE (document);
+  /* Don't call file handlers for file-exists-p, since they might
+     attempt to access the file, which could fail or produce undesired
+     consequences, see bug#16558 for an example.  */
+  handler = Ffind_file_name_handler (absdoc, Qfile_exists_p);
+  if (NILP (handler))
+    {
+      Lisp_Object absdoc_encoded = ENCODE_FILE (absdoc);
+
+      if (faccessat (AT_FDCWD, SSDATA (absdoc_encoded), F_OK, AT_EACCESS) == 0)
+       document = absdoc_encoded;
+      else
+       document = ENCODE_FILE (document);
+    }
+  else
+    document = ENCODE_FILE (document);
+  UNGCPRO;
   if (use_unicode)
     {
       wchar_t document_w[MAX_PATH], current_dir_w[MAX_PATH];