s3: vfs: shadow_copy2: Replace all uses of (p-name) with len_before_gmt.
authorJeremy Allison <jra@samba.org>
Wed, 17 Aug 2016 17:49:50 +0000 (10:49 -0700)
committerDavid Disseldorp <ddiss@samba.org>
Thu, 18 Aug 2016 00:51:15 +0000 (02:51 +0200)
p and name don't change, and we've already calculated this length.
Part of the effort to make the code inside vfs_snapper.c that does
the same thing more similar (we can't make these functions identical
due to the 'snapdir' use case).

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>
source3/modules/vfs_shadow_copy2.c

index 4ac16d3c10e2345cf9ae5fbe2f7f1411764947f5..2a72740d7297544939b45a522fe783ab49a99b4f 100644 (file)
@@ -514,7 +514,7 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
        q += 1;
 
        rest_len = strlen(q);
-       dst_len = (p-name) + rest_len;
+       dst_len = len_before_gmt + rest_len;
 
        if (priv->config->snapdirseverywhere) {
                char *insert;
@@ -580,10 +580,10 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
                        return false;
                }
                if (p > name) {
-                       memcpy(stripped, name, p-name);
+                       memcpy(stripped, name, len_before_gmt);
                }
                if (rest_len > 0) {
-                       memcpy(stripped + (p-name), q, rest_len);
+                       memcpy(stripped + len_before_gmt, q, rest_len);
                }
                stripped[dst_len] = '\0';
                *pstripped = stripped;