Date: Sat, 15 May 2004 17:11:53 -0700 (PDT) From: Dmitry Kazarov <kazarov@willcom.ru> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/66677: mv incorrectly copies somedir/.. to ./.. when it crossing devices. Message-ID: <200405160011.i4G0Brlk050520@www.freebsd.org> Resent-Message-ID: <200405160020.i4G0KHhu021670@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 66677 >Category: bin >Synopsis: mv incorrectly copies somedir/.. to ./.. when it crossing devices. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat May 15 17:20:14 PDT 2004 >Closed-Date: >Last-Modified: >Originator: Dmitry Kazarov >Release: FreeBSD 4.9 STABLE >Organization: MIDIKON >Environment: FreeBSD serv.willcom.ru 4.10-PRERELEASE FreeBSD 4.10-PRERELEASE #0: Thu May 6 12:04:39 MSD 2004 root@serv.willcom.ru:/var/obj/usr/src/sys/SERV i386 >Description: When moving dirs across devices it does not check for moving some/dir/.. over ./.. dir (or more generally it allows moving a dir over contents of existing dir). rename(2) disallows moving some/dir/.. over ./.. (but it works withing a filesystem). >How-To-Repeat: [697]$ cd [698]$ df . /var/tmp Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/vinum/home 3949805 2850542 783279 78% /home /dev/vinum/var 9290542 3212148 5335152 38% /var [699]$ mkdir -p /var/tmp/1/1 [700]$ touch /var/tmp/1/11 /var/tmp/1/12; [701]$ mkdir -p 2/2; cd 2/2 [702]$ ls [703]$ ls .. 2 [704]$ mv /var/tmp/1/1/.. . mv: "." and ".." may not be removed mv: /bin/rm: terminated with 1 (non-zero) status: Cross-device link [705]$ ls .. 1 11 12 2 BUT [710]$ cd [711]$ mkdir -p 1/1; touch 1/11 1/12 [712]$ mkdir -p 2/2 [713]$ cd 2/2 [714]$ mv ../../1/1/.. . mv: rename ../../1/1/.. to ./..: Invalid argument >Fix: --- mv.c.orig Sun May 16 04:04:29 2004 +++ mv.c Sun May 16 04:11:04 2004 @@ -145,6 +145,9 @@ if ((baselen + (len = strlen(p))) >= PATH_MAX) { warnx("%s: destination pathname too long", *argv); rval = 1; + } else if( strcmp("..",p) == 0 ) { + warnx("moving '..' is not allowed"); + rval = 1; } else { memmove(endp, p, (size_t)len + 1); if (do_move(*argv, path)) >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405160011.i4G0Brlk050520>