aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-12-03 11:49:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-12-03 11:49:23 +0100
commitcf2600c3661c11491a838ef29733583afb6ad968 (patch)
treef908ec99c481718fa2075dbd1917a7a9edb0a878
parent7d877fc9312a742b06125927bb1d34bd35398c6c (diff)
downloadbusybox-cf2600c3661c11491a838ef29733583afb6ad968.tar.gz
install: fix musl problem with dirname
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/install.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/coreutils/install.c b/coreutils/install.c
index e68589229..d0dcd0e89 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)