From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#33524: 27.0.50; Suspicious code in flymake-proc around temporary directories Date: Fri, 30 Nov 2018 14:00:19 +0000 Message-ID: References: <874lc18too.fsf@gmx.de> <87tvjyg1pu.fsf@gmx.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000ea01b4057be23862" X-Trace: blaine.gmane.org 1543586352 15236 195.159.176.226 (30 Nov 2018 13:59:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 30 Nov 2018 13:59:12 +0000 (UTC) Cc: Philipp Stephani , 33524@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 30 14:59:08 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSjJz-0003sb-Pf for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Nov 2018 14:59:08 +0100 Original-Received: from localhost ([::1]:60208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSjM6-0002un-8k for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Nov 2018 09:01:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSjLt-0002u8-NZ for bug-gnu-emacs@gnu.org; Fri, 30 Nov 2018 09:01:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSjLq-00027X-8O for bug-gnu-emacs@gnu.org; Fri, 30 Nov 2018 09:01:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51383) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSjLq-00027T-3p for bug-gnu-emacs@gnu.org; Fri, 30 Nov 2018 09:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gSjLp-00063O-Td for bug-gnu-emacs@gnu.org; Fri, 30 Nov 2018 09:01:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Nov 2018 14:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33524 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 33524-submit@debbugs.gnu.org id=B33524.154358643823234 (code B ref 33524); Fri, 30 Nov 2018 14:01:01 +0000 Original-Received: (at 33524) by debbugs.gnu.org; 30 Nov 2018 14:00:38 +0000 Original-Received: from localhost ([127.0.0.1]:55641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSjLS-00062g-3K for submit@debbugs.gnu.org; Fri, 30 Nov 2018 09:00:38 -0500 Original-Received: from mail-qt1-f172.google.com ([209.85.160.172]:43698) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSjLQ-00062U-Qx for 33524@debbugs.gnu.org; Fri, 30 Nov 2018 09:00:37 -0500 Original-Received: by mail-qt1-f172.google.com with SMTP id i7so5935304qtj.10 for <33524@debbugs.gnu.org>; Fri, 30 Nov 2018 06:00:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cdpI/EfBC9K4fjV+nhgJKK4Fg02cx158hXkCbrGmatI=; b=lLea3PYiYexzD00/eMRJxgasKU+HCCfDjeBfztuFq9bEJ7dP9vEFPrlw+dW9N1qvUL erHwfrtCBwF+A5MOmToDrinajyY3qcuzc32K8tDE+ZwkrjRM1uDzSD99kBkNLzErcmdt efXPyFsJGO1ORfL2DkKJD91cyqsI66DfdMH+PxBmj+nwlcNyWNmjacRiWhh75NrgDFsJ 3mzvPEWKnZlu0rqNpQ72AInVEQKxwQEmL9vE2yzY7ZCNyrL82C6sFyc7npWVLNDt6khy Dw18mKlWKEc6VD2lbYEgx28r8yLiRt2zeda9fsAtPGaZLs1gf/BAAWb0vci0Tb2ZiHsv L6xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cdpI/EfBC9K4fjV+nhgJKK4Fg02cx158hXkCbrGmatI=; b=GkfDukF2dwzSzG1qnShMprv4mLp1p2HaPTHDMS/68NVOGhVNJps9uLbwN6A+5299PQ VPG/N6RQdXaX4exf76KSKf7EyET2w236JvpD2Ho7OeOT7gvekHwZxo5AwZr5s9sPvcRn HmqQuhZA7Dbq8LHFeRCIuEfyYEjHFJIq0JzheZll77cI412LZkvGxvCOTXyMlLJNi/Bz d/+o5CSGuD08hPmxN5jbxmSSjjRbgbIBAuDPwWWs2bMsT49GPNv59fSkfqle0EHwkGj2 VuT5FMmsZAkBjrgBsOIlSNY2tLO82zaTbwWpArdaIvH2SWL6VSxs7uBJK2j+cswOX5Ku +qIw== X-Gm-Message-State: AA+aEWaNWtDKzRbmTGylX3LKAiUDLGvu6r5HALZI7nUaPRxWDnPg8nRz IXCR8TlKNGXG5SgDnTTmuI3K57PiDjHkQrNY0V4= X-Google-Smtp-Source: AFSGD/XqdNeDBv0RkV01/T/llFK8n1HSX9712jy24uEGn5+gUsCHR1gHRYgPUD6F8An1wlt4L8gskSvXtE+XDk6T5ds= X-Received: by 2002:ac8:88:: with SMTP id c8mr5697799qtg.218.1543586431237; Fri, 30 Nov 2018 06:00:31 -0800 (PST) In-Reply-To: <87tvjyg1pu.fsf@gmx.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:152935 Archived-At: --000000000000ea01b4057be23862 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable No, it looks great, for all I know... Which is very little :-) Flymake-proc is the "legacy" backend that I packed up in a file. It probably has many such bugs. Thanks very much Michael and Philipp, Jo=C3=A3o On Fri, Nov 30, 2018 at 12:59 PM Michael Albinus wrote: > Philipp Stephani 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 () #)() > > flymake-proc-legacy-flymake(#f(compiled-function (&rest args) > > #)) > > flymake--run-backend(flymake-proc-legacy-flymake) > > #f(compiled-function (backend) #) > > (flymake-proc-legacy-flymake) > > run-hook-wrapped(#f(compiled-function (backend) # > 0x117b195>) flymake-proc-legacy-flymake) > > flymake-start((post-command) nil) > > #f(compiled-function () #)() > > set-window-buffer(nil #) > > switch-to-buffer(#) > > ediff-setup-windows-multiframe-compare(# # > b.java> nil #) > > ediff-setup-windows-multiframe(# # nil > > #) > > ediff-setup-windows-default(# # nil > > #) > > ediff-setup-windows(# # nil # > *Ediff Control Panel*>) > > ediff-setup(# "/:/tmp/a.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: > > 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)) > > 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=C3=A3o, do you have further remarks? > > Best regards, Michael. > --=20 Jo=C3=A3o T=C3=A1vora --000000000000ea01b4057be23862 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
No, it looks great, for all I know... Which is very l= ittle :-)

Flymake-proc is the "legacy" b= ackend that I packed up in a file. It probably has many such bugs.

Thanks very much Michael and Philipp,
Jo=C3= =A3o



On Fri, Nov 30, 2018 at 12:59 PM Michael Albinus <= ;michael.albinus@gmx.de> w= rote:
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<= br> > 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&qu= ot;))'
>
> And Emacs immediately hangs because it runs into the endless loop.
> Stacktrace in this case is
>
> Debugger entered--Lisp error: (quit)
>=C2=A0 =C2=A0display-warning((flymake flymake-proc) "Failed to del= ete dir /,
> error ignored" :error "*Flymake log*")
>=C2=A0 =C2=A0flymake--log-1(1 flymake-proc "Failed to delete dir %= s, error
> ignored" "/")
>=C2=A0 =C2=A0flymake-proc--safe-delete-directory("/")
>=C2=A0 =C2=A0flymake-proc--delete-temp-directory("/tmp/:/tmp/"= ;)
>=C2=A0 =C2=A0flymake-proc-simple-java-cleanup()
>=C2=A0 =C2=A0#f(compiled-function () #<bytecode 0x11a4ea9>)()
>=C2=A0 =C2=A0flymake-proc-legacy-flymake(#f(compiled-function (&res= t args)
> #<bytecode 0x11a4e51>))
>=C2=A0 =C2=A0flymake--run-backend(flymake-proc-legacy-flymake)
>=C2=A0 =C2=A0#f(compiled-function (backend) #<bytecode 0x117b195>= )
> (flymake-proc-legacy-flymake)
>=C2=A0 =C2=A0run-hook-wrapped(#f(compiled-function (backend) #<bytec= ode
> 0x117b195>) flymake-proc-legacy-flymake)
>=C2=A0 =C2=A0flymake-start((post-command) nil)
>=C2=A0 =C2=A0#f(compiled-function () #<bytecode 0x1180771>)()
>=C2=A0 =C2=A0set-window-buffer(nil #<buffer a.java>)
>=C2=A0 =C2=A0switch-to-buffer(#<buffer a.java>)
>=C2=A0 =C2=A0ediff-setup-windows-multiframe-compare(#<buffer a.java&= gt; #<buffer
> b.java> nil #<buffer *Ediff Control Panel*>)
>=C2=A0 =C2=A0ediff-setup-windows-multiframe(#<buffer a.java> #<= ;buffer b.java> nil
> #<buffer *Ediff Control Panel*>)
>=C2=A0 =C2=A0ediff-setup-windows-default(#<buffer a.java> #<bu= ffer b.java> nil
> #<buffer *Ediff Control Panel*>)
>=C2=A0 =C2=A0ediff-setup-windows(#<buffer a.java> #<buffer b.j= ava> nil #<buffer
> *Ediff Control Panel*>)
>=C2=A0 =C2=A0ediff-setup(#<buffer a.java> "/:/tmp/a.java&quo= t; #<buffer b.java>
> "/:/tmp/b.java" nil nil nil ((ediff-job-name . ediff-files))= nil)
>=C2=A0 =C2=A0ediff-files-internal("/:/tmp/a.java" "/:/tm= p/b.java" nil nil
> ediff-files)
>=C2=A0 =C2=A0ediff("/:/tmp/a.java" "/:/tmp/b.java")=
>=C2=A0 =C2=A0(progn (add-hook (quote prog-mode-hook) (quote flymake-mod= e)) (ediff
> "/:/tmp/a.java" "/:/tmp/b.java"))
>=C2=A0 =C2=A0eval((progn (add-hook (quote prog-mode-hook) (quote flymak= e-mode))
> (ediff "/:/tmp/a.java" "/:/tmp/b.java")))
>=C2=A0 =C2=A0command-line-1(("-f" "toggle-debug-on-quit&= quot; "-eval" "(progn
> (add-hook (quote prog-mode-hook) (quote flymake-mode)) (ediff
> \"/:/tmp/a.java\" \"/:/tmp/b.java\"))"))
>=C2=A0 =C2=A0command-line()
>=C2=A0 =C2=A0normal-top-level()

The following patch fixes this problem:

diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.e= l
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
=C2=A0 =C2=A0(unless (stringp file-name)
=C2=A0 =C2=A0 =C2=A0(error "Invalid file-name"))

-=C2=A0 (let* ((dir=C2=A0 =C2=A0 =C2=A0 =C2=A0(file-name-directory file-nam= e))
+=C2=A0 (let* ((dir=C2=A0 =C2=A0 =C2=A0 =C2=A0(file-name-directory (file-na= me-unquote file-name)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Not sure what this slash-pos is all a= bout, but I guess it's just
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; trying to remove the leading / of abs= olute file names.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(slash-pos (string-match "/" di= r))

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

Jo=C3=A3o, do you have further remarks?

Best regards, Michael.


--
Jo=C3=A3o T=C3=A1vora --000000000000ea01b4057be23862--