]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:util: Fix string check in mkdir_p()
authorAndreas Schneider <asn@samba.org>
Tue, 8 May 2018 07:22:00 +0000 (09:22 +0200)
committerKarolin Seeger <kseeger@samba.org>
Wed, 20 Jun 2018 07:22:24 +0000 (09:22 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
(cherry picked from commit 7cec343a89a0862c09f5ddd4707eb442157a4af2)

lib/util/mkdir_p.c

index 290a1f395206436269901477ac8840a25886f32d..87a3f797618442403a106bf7ee9906056556007f 100644 (file)
@@ -49,11 +49,11 @@ int mkdir_p(const char *dir, int mode)
 
        /* Create ancestors */
        len = strlen(dir);
-       if (len >= PATH_MAX) {
+       ret = snprintf(t, sizeof(t), "%s", dir);
+       if (ret != len) {
                errno = ENAMETOOLONG;
                return -1;
        }
-       strncpy(t, dir, len+1);
 
        ret = mkdir_p(dirname(t), mode);
        if (ret != 0) {