all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
To: 18063@debbugs.gnu.org
Cc: public-notmuch-gxuj+Tv9EO5zyzON3hdc1g@plane.gmane.org,
	public-bug-gnu-emacs-mXXj517/zsQ@plane.gmane.org
Subject: bug#18063: 24.3; gnus-recursive-directory-files is fooled by upward symlinks
Date: Tue, 22 Jul 2014 08:45:15 +0900	[thread overview]
Message-ID: <b4m4myas2d0.fsf@jpl.org> (raw)
In-Reply-To: <871ttg6rs2.fsf@maritornes.cs.unb.ca>

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

On Sun, 20 Jul 2014 11:14:53 -0300, David Bremner wrote:
> Hi Emacs Maintainers;

Hi,

Hmm, why has your original message not been accepted as a bug in
the Emacs bug list? (I found it in the gmane.emacs.bugs newsgroup,
so I'm cc'ing this to the group.)

> A notmuch-emacs user reported a bug with emacs "hanging" on unpacking a
> tar file.  After some debugging I believe have narrowed the problem down
> to the following test case, which can be run with e.g.

> % emacs -Q --script bug.el

> (require 'gnus-util)

> (let* ((temp-dir (make-temp-file "/tmp/loop-test" t))
>        (dir (concat temp-dir "/test"))
>        (target (concat dir "/parent")))
>   (make-temp-file dir)
>   (make-directory dir)
>   (make-symbolic-link ".." target)
>   (message "%s" (gnus-recursive-directory-files dir)))

> On my system, this reports some 40 spurious paths created by following
> the symlink.  In the actual case, it reported some 70,000 paths, which
> caused further processing by the mm- libraries to grind to take an
> apparently infinite time.

The following patch fixes the problem at least on Cygwin.  Is it
ok for yours, too?  If so, I'll install it in the Emacs trunk (i.e.
the one that will become Emacs 24.5) and also the Gnus Git master.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 822 bytes --]

--- gnus-util.el~	2014-03-23 23:08:55.000000000 +0000
+++ gnus-util.el	2014-07-21 23:43:08.029233200 +0000
@@ -1910,7 +1910,7 @@
                    image)))
       image)))
 
-(defun gnus-recursive-directory-files (dir)
+(defun gnus-recursive-directory-files (dir &optional inodes)
   "Return all regular files below DIR."
   (let (files)
     (dolist (file (directory-files dir t))
@@ -1920,7 +1920,11 @@
 	 ((file-regular-p file)
 	  (push file files))
 	 ((file-directory-p file)
-	  (setq files (append (gnus-recursive-directory-files file) files))))))
+	  (let ((inode (nth 10 (file-attributes file))))
+	    (unless (member inode inodes)
+	      (setq files (append (gnus-recursive-directory-files
+				   file (cons inode inodes))
+				  files))))))))
     files))
 
 (defun gnus-list-memq-of-list (elements list)

  reply	other threads:[~2014-07-21 23:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-20 14:14 24.3; gnus-recursive-directory-files is fooled by upward symlinks David Bremner
2014-07-21 23:45 ` Katsumi Yamaoka [this message]
2014-07-22  0:34   ` bug#18063: " Glenn Morris
2014-07-22  5:17     ` Katsumi Yamaoka
2014-07-22  5:59       ` Glenn Morris
2014-07-22  6:37       ` Katsumi Yamaoka

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

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

  git send-email \
    --in-reply-to=b4m4myas2d0.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=18063@debbugs.gnu.org \
    --cc=public-bug-gnu-emacs-mXXj517/zsQ@plane.gmane.org \
    --cc=public-notmuch-gxuj+Tv9EO5zyzON3hdc1g@plane.gmane.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.