Re: file stat bug (infinite loop) in 2.0.4?

Miek Gieben <[email protected]> Mon, 17 Jan 2005 11:40:45 +0100
Newsgroups gmane.comp.sysutils.backup.hdup.general
Message-ID <[email protected]>
[On 14 Jan, @ 17:01, Robert wrote in "[hdup-user] file stat bug (inf ..."]
> When I run a backup on a system where I specify a nonexistent directory 
> to backup, hdup-2.0.4 seems tp go into an infinite loop:
> 
> [backup@hdup-server backup]$ ssh client sudo /usr/sbin/hdup weekly 
> client @[email protected]
> /usr/sbin/hdup: client: STARTING BACKUP.
> /usr/sbin/hdup: WARNING: Cannot stat: /var/bak!
> /usr/sbin/hdup: WARNING: Cannot stat: /var/bak!
> /usr/sbin/hdup: WARNING: Cannot stat: /var/bak!
> ...continues...
> 
> Of course, creating the directory causes the "warning" to go away. This 
> is a reasonable error to make, and hdup shouldn't go into an infinite loop!

I hate while-loops. The following patch fixes it:

Index: src/walker.c
===================================================================
--- src/walker.c        (revision 49)
+++ src/walker.c        (working copy)
@@ -112,6 +112,7 @@
                /* path[i] can also be a file - test that first */
                if(lstat(host->path[i], &s) != 0) {
                        WARN("%s: %s", "Cannot stat", host->path[i]);
+                       i++; /* BUG #6 */
                        continue;
                }
 


I will be releasing a 2.0.5, with some other bugs fixed too. This in order
to get a bugfree version of hdup in Debian.

grtz Miek