[PATCH] handle dir entries with zero length(!)
Paul Slootman
paul at debian.org
Wed Aug 1 11:37:34 GMT 2007
It's probably a kernel bug, and I shouldn't have tried to backup /sys on
a linux system, but rsync dumped core on me due to the following:
$ ls -al /sys/module/usbcore/parameters | cat -vet
total 0$
drwxr-xr-x 2 root root 0 2007-07-26 18:50 $
drwxr-xr-x 2 root root 0 2007-07-26 18:50 .$
drwxr-xr-x 4 root root 0 2007-06-15 20:34 ..$
-rw-r--r-- 1 root root 4096 2007-07-26 18:50 autosuspend$
-r--r--r-- 1 root root 4096 2007-07-26 18:50 blinkenlights$
-rw-r--r-- 1 root root 4096 2007-07-26 18:50 old_scheme_first$
-rw-r--r-- 1 root root 4096 2007-07-26 18:50 use_both_schemes$
Note the entry with an empty name...
Rsync was hitting that and then recursively trying to list that
directory again, until the stack overflowed.
As other tools seem to handle this situation gracefully (for example
cp -a, find), and dumping core is never a nice thing to do, I thought
that rsync should handle this gracefully as well. The following patch
(against CVS) to flist.c fixes it for me and gives an error message
"cannot send file with empty name "...."". The way I show the directory
where the empty file is might be improved...
Paul Slootman
--- flist.c.orig 2007-08-01 13:31:11.000000000 +0200
+++ flist.c 2007-08-01 13:32:49.000000000 +0200
@@ -1462,6 +1462,20 @@
if (dname[0] == '.' && (dname[1] == '\0'
|| (dname[1] == '.' && dname[2] == '\0')))
continue;
+ if (dname[0] == '\0') {
+ char replaced = 0;
+ io_error |= IOERR_GENERAL;
+ if (len > 0) {
+ replaced = fbuf[len+1];
+ fbuf[len+1] = '\0';
+ }
+ rprintf(FINFO,
+ "cannot send file with empty name %s\n",
+ full_fname(fbuf));
+ if (replaced)
+ fbuf[len+1] = replaced;
+ continue;
+ }
if (strlcpy(p, dname, remainder) >= remainder) {
io_error |= IOERR_GENERAL;
rprintf(FINFO,
More information about the rsync
mailing list