unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch-new.c infinite recursion symlink bug
@ 2011-06-10  7:32 Taylor Carpenter
  2011-06-10  7:50 ` Taylor Carpenter
  2011-06-21 12:42 ` Daniel Kahn Gillmor
  0 siblings, 2 replies; 5+ messages in thread
From: Taylor Carpenter @ 2011-06-10  7:32 UTC (permalink / raw)
  To: notmuch

If a symlink points to . then there will be an infinite recursion.  The included patch fixes that.


--- notmuch-new.c.orig  2011-06-10 00:03:09.000000000 -0500
+++ notmuch-new.c 2011-06-10 02:10:37.000000000 -0500
@@ -233,6 +233,8 @@
     struct stat st;
     notmuch_bool_t is_maildir, new_directory;
     const char **tag;
+    char lpath[PATH_MAX], filepath[PATH_MAX];
+    size_t len;
 
     if (stat (path, &st)) {
  fprintf (stderr, "Error reading directory %s: %s\n",
@@ -296,6 +298,14 @@
   */
  /* XXX: Eventually we'll want more sophistication to let the
   * user specify files to be ignored. */
+
+ if (entry->d_type == DT_LNK) {
+     snprintf(filepath, sizeof(filepath), "%s/%s", path, entry->d_name);
+     if ((len = readlink(filepath, lpath, sizeof(lpath))) > 0)
+         if (strncmp(lpath, ".", len-1) == 0)
+             continue;
+ }
+
  if (strcmp (entry->d_name, ".") == 0 ||
      strcmp (entry->d_name, "..") == 0 ||
      (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-06-21 21:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-10  7:32 [PATCH] notmuch-new.c infinite recursion symlink bug Taylor Carpenter
2011-06-10  7:50 ` Taylor Carpenter
2011-06-21 12:42 ` Daniel Kahn Gillmor
2011-06-21 16:01   ` Austin Clements
2011-06-21 21:50     ` Carl Worth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.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).