s3: vfs: snapper: Fix snapper_gmt_strip_snapshot() function to strip @GMT token ident...
authorJeremy Allison <jra@samba.org>
Wed, 17 Aug 2016 17:57:10 +0000 (10:57 -0700)
committerDavid Disseldorp <ddiss@samba.org>
Thu, 18 Aug 2016 04:43:02 +0000 (06:43 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12150

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Thu Aug 18 06:43:02 CEST 2016 on sn-devel-144

source3/modules/vfs_snapper.c

index f5ccc15f4836daba73b580940631c5202fa874ab..5c1821d98f1b7e00416b36d123a9b5c78c48d4ea 100644 (file)
@@ -1748,9 +1748,23 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX *mem_ctx,
        if (timestamp == (time_t)-1) {
                goto no_snapshot;
        }
-       if ((p == name) && (q[0] == '\0')) {
+       if (q[0] == '\0') {
+               /*
+                * The name consists of only the GMT token or the GMT
+                * token is at the end of the path. XP seems to send
+                * @GMT- at the end under certain circumstances even
+                * with a path prefix.
+                */
                if (pstripped != NULL) {
-                       stripped = talloc_strdup(mem_ctx, "");
+                       if (len_before_gmt > 0) {
+                               /*
+                                * There is a slash before
+                                * the @GMT-. Remove it.
+                                */
+                               len_before_gmt -= 1;
+                       }
+                       stripped = talloc_strndup(mem_ctx, name,
+                                       len_before_gmt);
                        if (stripped == NULL) {
                                return false;
                        }
@@ -1760,6 +1774,10 @@ static bool snapper_gmt_strip_snapshot(TALLOC_CTX *mem_ctx,
                return true;
        }
        if (q[0] != '/') {
+               /*
+                * It is not a complete path component, i.e. the path
+                * component continues after the gmt-token.
+                */
                goto no_snapshot;
        }
        q += 1;