summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsystem/libsystem.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/libsystem/libsystem.c b/src/libsystem/libsystem.c
index f7aa2e3..f87dfa0 100644
--- a/src/libsystem/libsystem.c
+++ b/src/libsystem/libsystem.c
@@ -424,26 +424,22 @@ int do_copy(const char *src, const char *dst, const char *option, int64_t timeou
}
int do_mkdir(const char *path, mode_t mode) {
+ char d[PATH_MAX];
size_t s, l;
- int p;
- int r;
+ int r, p;
assert(path);
l = strlen(path);
- for (p = 0, s = 0; p < l; p += s+1) {
- _cleanup_free_ char *d = NULL;
-
- s = strcspn(path+p, "/");
+ for (p = 0, s = 0; p < l; p += s + 1) {
+ s = strcspn(path + p, "/");
if (!s)
continue;
- d = new0(char, p+s+1);
- if (!d)
- return -ENOMEM;
+ assert(PATH_MAX > p + s + 1);
- r = snprintf(d, p+s+1, "%s", path);
+ r = snprintf(d, p + s + 1, "%s", path);
if (r < 0)
return r;