Thanks for the reports and patch.
I don't see what version of mv you're using, but suspect it's
no newer than the one from fileutils-4.0.

That bug is fixed in the latest test release.
(and in every test release since 4.0)

  ftp://alpha.gnu.org/gnu/fetish/fileutils-4.0w.tar.gz

[btw, you shouldn't use strdup there -- it'd introduce a leak]

"Daniel R. Grayson" <[EMAIL PROTECTED]> writes:
| It turns out to be a memory allocation bug.  Sometimes "mv" has to copy the
| files, instead of moving them, for example, when moving from one filesystem
| to another.  So keeps track of the inode numbers of the files it's already
| moved, so in case it is about to move another link to a file it's already
| moved, it can simply make a new link on the new file system.  Unfortunately,
| when it saves the destination name of that earlier file, it forgets to create
| a new copy of the string, so the memory for that string gets freed, the next
| string gets the same memory, and over-writes it.
|
| Here is a fix.
|
| rhenium# diff -u fileutils-4.0/src/cp-hash.c-orig fileutils-4.0/src/cp-hash.c
| --- fileutils-4.0/src/cp-hash.c-orig  Tue Jul 18 19:40:37 2000
| +++ fileutils-4.0/src/cp-hash.c       Tue Jul 18 19:40:42 2000
| @@ -156,7 +156,7 @@
|    ep = *hp = &ht->entry_tab[ht->first_free_entry++];
|    ep->ino = ino;
|    ep->dev = dev;
| -  ep->node = (char *) node;
| +  ep->node = (char *) strdup(node);
|    ep->coll_link = ep2;               /* ep2 is NULL if not collision.  */
|
|    return NULL;
[...]

Reply via email to