s3-sysquotas: correctly restore path when finding mount point
authorUri Simchoni <uri@samba.org>
Fri, 7 Oct 2016 08:05:07 +0000 (11:05 +0300)
committerJeremy Allison <jra@samba.org>
Sat, 8 Oct 2016 03:22:25 +0000 (05:22 +0200)
When traversing the path backwards to find the mount point, if the
root '/' is reached, then the character to be restored is not a '/'.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12273

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Oct  8 05:22:25 CEST 2016 on sn-devel-144

source3/lib/sysquotas.c

index c2d09dabf1be531e8c4978662e2ec252ca60bb69..eef87beafe0a940d70d9af0cc1acb605f4f36ee8 100644 (file)
@@ -82,6 +82,8 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
        }
 
        while (true) {
+               char save_ch;
+
                p = strrchr(stat_mntpath, '/');
                if (p == NULL) {
                        DBG_ERR("realpath for %s does not begin with a '/'\n",
@@ -93,6 +95,7 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
                        ++p;
                }
 
+               save_ch = *p;
                *p = 0;
                if (sys_stat(stat_mntpath, &S, false) != 0) {
                        DBG_WARNING("cannot stat real path component %s - %s\n",
@@ -100,7 +103,7 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
                        goto out;
                }
                if (S.st_ex_dev != devno) {
-                       *p = '/';
+                       *p = save_ch;
                        break;
                }