zic.c:mkdirs broken
Roland McGrath
roland at gnu.ai.mit.edu
Wed Feb 9 19:11:30 UTC 1994
The fix I sent before for this never made it into 94b. I don't know how
this fails to break everyone else. mkdirs is broken unless you compile
with -fwritable-strings (which is generally losing to do).
diff -u /home/gd3/roland/libc/time/zic.c.\~4\~ /home/gd3/roland/libc/time/zic.c
--- /home/gd3/roland/libc/time/zic.c.~4~ Mon Feb 7 14:30:53 1994
+++ /home/gd3/roland/libc/time/zic.c Wed Feb 9 14:09:11 1994
@@ -1877,14 +1877,20 @@
charcnt += eitol(i);
}
+
static int
-mkdirs(name)
-char * const name;
+mkdirs(argname)
+char * const argname;
{
register char * cp;
+ /* We must make a copy in case the
+ passed pointer is a read-only string. */
+ char *name = ecpyalloc (argname);
- if ((cp = name) == NULL || *cp == '\0')
- return 0;
+ if ((cp = name) == NULL || *cp == '\0') {
+ free (name);
+ return 0;
+ }
while ((cp = strchr(cp + 1, '/')) != 0) {
*cp = '\0';
#ifndef unix
@@ -1906,11 +1912,13 @@
"%s: Can't create directory ",
progname);
(void) perror(name);
+ free (name);
return -1;
}
}
*cp = '/';
}
+ free (name);
return 0;
}
Diff exited abnormally with code 1 at Wed Feb 9 14:09:45
More information about the tz
mailing list