bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Infinite loop on symlinks.] don't we need to check the dev?


From: Jeff Bailey
Subject: Re: [Infinite loop on symlinks.] don't we need to check the dev?
Date: Sun, 17 Feb 2002 08:21:42 -0800
User-agent: Mutt/1.2.5i

It's uglier, but we could also hard code a max depth of something like
10 and wait for people to notice.

On Sat, Feb 16, 2002 at 11:14:21AM -0500, Sam Roberts wrote:
> Hi Sergey,
> 
> Building a linked list on that stack is clever, I don't recall
> seeing that before.
> 
> Since inodes aren't unique across devices, don't you need to check
> both dev and inode?
> 
> Sam
> 
> 
> Quoting Jeff Bailey <address@hidden>, who wrote:
> > ----- Forwarded message from Norbert Veber <address@hidden> -----
> > 
> > Subject: Bug#134330: mailutils-imap4d: Infinite loop on symlinks.
> > 
> > Package: mailutils-imap4d
> > Version: 20011103-1.1
> > Severity: important
> > 
> > In my directory, I have this:
> > address@hidden:~/.gnome-desktop]$ ls -al
> > total 20
> > drwxr-xr-x    3 nveber   nveber       4096 Feb 14 21:41 .
> > drwx--x--x  111 nveber   nveber       8192 Feb 16 21:11 ..
> > lrwxrwxrwx    1 nveber   nveber          6 Feb 14 21:39 cdrom -> /cdrom
> > lrwxrwxrwx    1 nveber   nveber          7 Feb 14 21:39 fd0 -> /floppy
> > lrwxrwxrwx    1 nveber   nveber         12 Feb 14 21:39 Home directory
> > -> /home/nveber
> > -rwxr-xr-x    1 nveber   nveber         90 Jan  2 20:26 moviecd.sh
> > drwx------    2 nveber   nveber       4096 Feb 14 21:47 Trash.gmc
> > 
> > When getting the list of folders from the imap server, it enters into an
> > infite loop while listing the contents of my directory because of the 
> > symlink
> > that points back to my directory.  An strace shows its reading the same
> > directory over and over and over..
> > 
> > -- System Information
> > Debian Release: 3.0
> > Architecture: i386
> > Kernel: Linux pyre 2.4.17 #2 Sun Dec 23 16:22:24 EST 2001 i686
> > Locale: LANG=en_US, LC_CTYPE=en_US
> > 
> > Versions of packages mailutils-imap4d depends on:
> > ii  libc6                       2.2.5-3      GNU C Library: Shared 
> > libraries an
> > ii  libmailutils0               20011103-1.1 GNU Mail Abstraction library
> > ii  libpam0g                    0.72-35      Pluggable Authentication 
> > Modules l
> > ii  netbase                     4.07         Basic TCP/IP networking system
> 
> -- 
> Sam Roberts <address@hidden> (Vivez sans temps mort!)

> Index: imap4d/list.c
> ===================================================================
> RCS file: /cvsroot/mailutils/mailutils/imap4d/list.c,v
> retrieving revision 1.11
> diff -u -r1.11 list.c
> --- imap4d/list.c     17 Feb 2002 14:13:50 -0000      1.11
> +++ imap4d/list.c     17 Feb 2002 16:00:56 -0000
> @@ -30,6 +30,7 @@
>  {
>    struct inode_list *next;
>    ino_t inode;
> +  dev_t dev;
>  };
>  
>  /*
> @@ -168,6 +169,7 @@
>         stat (cwd, &st);
>         inode_rec.next = NULL;
>         inode_rec.inode = st.st_ino;
> +       inode_rec.dev   = st.st_dev;
>         list_file (cwd, ref, (dir) ? dir : "", delim, &inode_rec);
>         chdir (homedir);
>       }
> @@ -179,10 +181,10 @@
>  }
>  
>  static int
> -inode_list_lookup (struct inode_list *list, ino_t inode)
> +inode_list_lookup (struct inode_list *list, struct stat* st)
>  {
>    for (; list; list = list->next)
> -    if (list->inode == inode)
> +    if (list->inode == st->st_ino && list->dev == st->st_dev)
>        return 1;
>    return 0;
>  }
> @@ -248,7 +250,7 @@
>                       print_dir (ref, entry, delim);
>  
>                     if (S_ISDIR (st.st_mode)
> -                       && inode_list_lookup (inode_list, st.st_ino) == 0)
> +                       && inode_list_lookup (inode_list, &st) == 0)
>                       {
>                         if (chdir (entry) == 0)
>                           {
> @@ -257,6 +259,7 @@
>                             struct inode_list inode_rec;
>  
>                             inode_rec.inode = st.st_ino;
> +                           inode_rec.dev   = st.st_dev;
>                             inode_rec.next = inode_list;
>                             rf = calloc (strlen (ref) + strlen (delim) +
>                                          strlen (entry) + 1, 1);


-- 
I gotta ding ding dang a dang a long ding dong.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]