dest = last;
if (opts & OPT_MKDIR_LEADING) {
char *ddir = xstrdup(dest);
- char *dn = dirname(ddir);
- /* musl can return read-only "/" or "." string.
- * bb_make_directory needs writable string.
+ bb_make_directory(dirname(ddir), 0755, mkdir_flags);
+ /* errors are not checked. copy_file
+ * will fail if dir is not created.
*/
- 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)
char c;
struct stat st;
- /* Happens on bb_make_directory(dirname("no_slashes"),...) */
- if (LONE_CHAR(path, '.'))
+ /* "path" can be a result of dirname().
+ * dirname("no_slashes") returns ".", possibly read-only.
+ * musl dirname() can return read-only "/" too.
+ * We need writable string. And for "/", "." (and ".."?)
+ * nothing needs to be created anyway.
+ */
+ if (LONE_CHAR(path, '/'))
return 0;
+ if (path[0] == '.') {
+ if (path[1] == '\0')
+ return 0; /* "." */
+// if (path[1] == '.' && path[2] == '\0')
+// return 0; /* ".." */
+ }
org_mask = cur_mask = (mode_t)-1L;
s = path;