about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2000-08-04 14:58:05 +0000
committerClint Adams <clint@users.sourceforge.net>2000-08-04 14:58:05 +0000
commit971f7c0a19eefebe90274fde29c33e3a3a04b552 (patch)
tree69be97ff85336d5312f9bb3e5693e2fbae70d307
parent8e740b7044b1538b51b1a58f27d92091c1e84a63 (diff)
downloadzsh-971f7c0a19eefebe90274fde29c33e3a3a04b552.tar.gz
zsh-971f7c0a19eefebe90274fde29c33e3a3a04b552.tar.xz
zsh-971f7c0a19eefebe90274fde29c33e3a3a04b552.zip
12533: pathconf() without tail in mkdir
-rw-r--r--ChangeLog5
-rw-r--r--Src/Modules/files.c18
2 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 73c9e0543..39e71f5d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-08-04  Clint Adams  <schizo@debian.org>
+
+	* 12533: Src/Modules/files.c: drop the tail of the path
+	passed to mkdir in the call to pathconf().
+
 2000-08-04  Sven Wischnowsky  <wischnow@zsh.org>
 
 	* 12525: Src/module.c: remove (wrong) test for linked-in modules
diff --git a/Src/Modules/files.c b/Src/Modules/files.c
index d01a59b03..ac775c75a 100644
--- a/Src/Modules/files.c
+++ b/Src/Modules/files.c
@@ -71,6 +71,7 @@ bin_mkdir(char *nam, char **args, char *ops, int func)
     mode_t oumask = umask(0);
     mode_t mode = 0777 & ~oumask;
     int err = 0;
+    char *head;
 
     umask(oumask);
     if(ops['m']) {
@@ -91,8 +92,19 @@ bin_mkdir(char *nam, char **args, char *ops, int func)
 
 	while(ptr > *args + (**args == '/') && *--ptr == '/')
 	    *ptr = 0;
-	if(zpathmax(unmeta(*args)) < 0) {
-	    zwarnnam(nam, "%s: %e", *args, errno);
+
+/* Drop the tail so that pathconf receives a potentially valid pathname */
+	head = (char *) ztrdup(*args);
+	if ((ptr = strrchr(head, '/')))
+	    *ptr = 0;
+	else {
+/* Relative to current directory */
+	    *head = '.';
+	    *(head + 1) = '\0';
+	}
+
+	if(zpathmax(unmeta(head)) < 0) {
+	    zwarnnam(nam, "%s: %e", head, errno);
 	    err = 1;
 	    continue;
 	}
@@ -121,6 +133,8 @@ bin_mkdir(char *nam, char **args, char *ops, int func)
 	    }
 	} else
 	    err |= domkdir(nam, *args, mode, 0);
+
+	free(head);
     }
     return err;
 }