[git commit] install: fix musl problem with dirname
Denys Vlasenko
vda.linux at googlemail.com
Sat Dec 3 10:49:23 UTC 2016
commit: https://git.busybox.net/busybox/commit/?id=cf2600c3661c11491a838ef29733583afb6ad968
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
coreutils/install.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/coreutils/install.c b/coreutils/install.c
index e685892..d0dcd0e 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -209,9 +209,16 @@ int install_main(int argc, char **argv)
dest = last;
if (opts & OPT_MKDIR_LEADING) {
char *ddir = xstrdup(dest);
- bb_make_directory(dirname(ddir), 0755, mkdir_flags);
- /* errors are not checked. copy_file
- * will fail if dir is not created. */
+ char *dn = dirname(ddir);
+ /* musl can return read-only "/" or "." string.
+ * bb_make_directory needs writable string.
+ */
+ if ((dn[0] != '/' && dn[0] != '.') || dn[1] != '\0') {
+ bb_make_directory(dn, 0755, mkdir_flags);
+ /* errors are not checked. copy_file
+ * will fail if dir is not created.
+ */
+ }
free(ddir);
}
if (isdir)
More information about the busybox-cvs
mailing list