unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: 33524@debbugs.gnu.org, "João Távora" <joaotavora@gmail.com>
Subject: bug#33524: 27.0.50; Suspicious code in flymake-proc around temporary directories
Date: Fri, 30 Nov 2018 13:59:57 +0100	[thread overview]
Message-ID: <87tvjyg1pu.fsf@gmx.de> (raw)
In-Reply-To: <CAArVCkRc9b8x2ZUmtZy2hEJssgY+FjCqf9C=D3NRcV52jNRQfA@mail.gmail.com> (Philipp Stephani's message of "Thu, 29 Nov 2018 10:48:42 +0100")

[-- Attachment #1: Type: text/plain, Size: 2832 bytes --]

Philipp Stephani <p.stephani2@gmail.com> writes:

Hi Philipp,

> Sorry for being imprecise. Yes, I mean quoted filenames. (It's
> possible that the issue also arises for true remote filenames, but I
> haven't checked.)

"True remote filename" is still a wrong phrase. Quoted file names and
remote file names play different games.

> You can easily reproduce user-facing problems. Assuming you have some
> binary installed that would check Java files using the legacy backend:
>
> $ touch /tmp/{a,b}.java
> $ emacs -Q -eval '(progn (add-hook (quote prog-mode-hook) (quote
> flymake-mode)) (ediff "/:/tmp/a.java" "/:/tmp/b.java"))'
>
> And Emacs immediately hangs because it runs into the endless loop.
> Stacktrace in this case is
>
> Debugger entered--Lisp error: (quit)
>   display-warning((flymake flymake-proc) "Failed to delete dir /,
> error ignored" :error "*Flymake log*")
>   flymake--log-1(1 flymake-proc "Failed to delete dir %s, error
> ignored" "/")
>   flymake-proc--safe-delete-directory("/")
>   flymake-proc--delete-temp-directory("/tmp/:/tmp/")
>   flymake-proc-simple-java-cleanup()
>   #f(compiled-function () #<bytecode 0x11a4ea9>)()
>   flymake-proc-legacy-flymake(#f(compiled-function (&rest args)
> #<bytecode 0x11a4e51>))
>   flymake--run-backend(flymake-proc-legacy-flymake)
>   #f(compiled-function (backend) #<bytecode 0x117b195>)
> (flymake-proc-legacy-flymake)
>   run-hook-wrapped(#f(compiled-function (backend) #<bytecode
> 0x117b195>) flymake-proc-legacy-flymake)
>   flymake-start((post-command) nil)
>   #f(compiled-function () #<bytecode 0x1180771>)()
>   set-window-buffer(nil #<buffer a.java>)
>   switch-to-buffer(#<buffer a.java>)
>   ediff-setup-windows-multiframe-compare(#<buffer a.java> #<buffer
> b.java> nil #<buffer *Ediff Control Panel*>)
>   ediff-setup-windows-multiframe(#<buffer a.java> #<buffer b.java> nil
> #<buffer *Ediff Control Panel*>)
>   ediff-setup-windows-default(#<buffer a.java> #<buffer b.java> nil
> #<buffer *Ediff Control Panel*>)
>   ediff-setup-windows(#<buffer a.java> #<buffer b.java> nil #<buffer
> *Ediff Control Panel*>)
>   ediff-setup(#<buffer a.java> "/:/tmp/a.java" #<buffer b.java>
> "/:/tmp/b.java" nil nil nil ((ediff-job-name . ediff-files)) nil)
>   ediff-files-internal("/:/tmp/a.java" "/:/tmp/b.java" nil nil
> ediff-files)
>   ediff("/:/tmp/a.java" "/:/tmp/b.java")
>   (progn (add-hook (quote prog-mode-hook) (quote flymake-mode)) (ediff
> "/:/tmp/a.java" "/:/tmp/b.java"))
>   eval((progn (add-hook (quote prog-mode-hook) (quote flymake-mode))
> (ediff "/:/tmp/a.java" "/:/tmp/b.java")))
>   command-line-1(("-f" "toggle-debug-on-quit" "-eval" "(progn
> (add-hook (quote prog-mode-hook) (quote flymake-mode)) (ediff
> \"/:/tmp/a.java\" \"/:/tmp/b.java\"))"))
>   command-line()
>   normal-top-level()

The following patch fixes this problem:


[-- Attachment #2: Type: text/plain, Size: 633 bytes --]

diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 8600be9b97..e969c5d992 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -874,7 +874,7 @@ flymake-proc-create-temp-with-folder-structure
   (unless (stringp file-name)
     (error "Invalid file-name"))
 
-  (let* ((dir       (file-name-directory file-name))
+  (let* ((dir       (file-name-directory (file-name-unquote file-name)))
          ;; Not sure what this slash-pos is all about, but I guess it's just
          ;; trying to remove the leading / of absolute file names.
 	 (slash-pos (string-match "/" dir))

[-- Attachment #3: Type: text/plain, Size: 279 bytes --]


However, I don't know whether this is sufficient, because I don't know
why you use quoted file names in your example. Is this something which
shall be preserved in the temporary directory, created by flymake?

João, do you have further remarks?

Best regards, Michael.

  reply	other threads:[~2018-11-30 12:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 16:37 bug#33524: 27.0.50; Suspicious code in flymake-proc around temporary directories Philipp Stephani
2018-11-28  8:58 ` Michael Albinus
2018-11-29  9:48   ` Philipp Stephani
2018-11-30 12:59     ` Michael Albinus [this message]
2018-11-30 14:00       ` João Távora
2018-11-30 14:12         ` Michael Albinus
2018-12-17 10:58           ` Michael Albinus
2018-12-17 20:57             ` Philipp Stephani
2018-12-17 21:08               ` Michael Albinus
2018-12-18 15:00                 ` Eli Zaretskii
2018-12-18 16:45                   ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tvjyg1pu.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=33524@debbugs.gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=p.stephani2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).