summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/mv/mv.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index 0553080..91217d3 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: mv.c,v 1.2 1994/09/24 02:56:07 davidg Exp $
*/
#ifndef lint
@@ -116,10 +116,16 @@ endarg: argc -= optind;
*endp++ = '/';
++baselen;
for (rval = 0; --argc; ++argv) {
- if ((p = strrchr(*argv, '/')) == NULL)
- p = *argv;
- else
- ++p;
+ /*
+ * Find the last component of the source pathname. It
+ * may have trailing slashes.
+ */
+ p = *argv + strlen(*argv);
+ while (p != *argv && p[-1] == '/')
+ --p;
+ while (p != *argv && p[-1] != '/')
+ --p;
+
if ((baselen + (len = strlen(p))) >= MAXPATHLEN) {
warnx("%s: destination pathname too long", *argv);
rval = 1;
OpenPOWER on IntegriCloud