Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jun 2002 04:04:25 +0200 (CEST)
From:      Serge van den Boom <svdb@stack.nl>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/39318: /bin/mv executes /bin/cp and /bin/rm without --
Message-ID:  <20020615020425.7DE8B5A@inferno.stuiver.net>

next in thread | raw e-mail | index | archive | help


>Number:         39318
>Category:       bin
>Synopsis:       /bin/mv executes /bin/cp and /bin/rm without --
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 14 19:20:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Serge van den Boom
>Release:        FreeBSD 4.5-RELEASE i386
>Organization:
M.C.G.V. Stack
>Environment:
System: FreeBSD inferno.stuiver.net 4.5-RELEASE FreeBSD 4.5-RELEASE #0: Sun Mar 17 04:23:07 CET 2002 svdb@inferno.stuiver.net:/usr/src/sys/compile/INFERNO i386
>Description:
When moving a directory to another filesystem, /bin/mv executes /bin/cp
and /bin/mv, without '--', so that filenames starting with '-' are
interpreted as options to /bin/cp and /bin/mv.

>How-To-Repeat:
mkdir -- -v
mv -- -v /tmp  # where /tmp is on another filesystem

>Fix:

diff -u mv/mv.c mv.patched/mv.c
--- mv/mv.c	Sat Jun 15 03:10:09 2002
+++ mv.patched/mv.c	Sat Jun 15 03:11:23 2002
@@ -331,7 +331,7 @@
 	int pid, status;
 
 	if ((pid = fork()) == 0) {
-		execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", from, to,
+		execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", "--", from, to,
 		    (char *)NULL);
 		warn("%s", _PATH_CP);
 		_exit(1);
@@ -350,7 +350,7 @@
 		return (1);
 	}
 	if (!(pid = vfork())) {
-		execl(_PATH_RM, "mv", "-rf", from, (char *)NULL);
+		execl(_PATH_RM, "mv", "-rf", "--", from, (char *)NULL);
 		warn("%s", _PATH_RM);
 		_exit(1);
 	}


>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020615020425.7DE8B5A>