From 9c195321345846195e465158f88dad5fd7699389 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 18 Oct 2012 15:24:39 +0200 Subject: [PATCH] s3-shadow-copy2: Protect against already converted names Signed-off-by: Volker Lendecke Reviewed-by: Christof Schmitt Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Fri Jun 27 09:03:53 CEST 2014 on sn-devel-104 --- source3/modules/vfs_shadow_copy2.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 30f67e27823..439df5ddf4d 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -235,6 +235,9 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx, char *stripped; size_t rest_len, dst_len; struct shadow_copy2_config *config; + const char *snapdir; + ssize_t snapdirlen; + ptrdiff_t len_before_gmt; SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config, return false); @@ -252,6 +255,31 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx, p, name, (int)p[-1])); goto no_snapshot; } + + /* + * Figure out whether we got an already converted string. One + * case where this happens is in a smb2 create call with the + * mxac create blob set. We do the get_acl call on + * fsp->fsp_name, which is already converted. We are converted + * if we got a file name of the form ".snapshots/@GMT-", + * i.e. ".snapshots/" precedes "p". + */ + + snapdir = lp_parm_const_string(SNUM(handle->conn), "shadow", "snapdir", + ".snapshots"); + snapdirlen = strlen(snapdir); + len_before_gmt = p - name; + + if ((len_before_gmt >= (snapdirlen + 1)) && (p[-1] == '/')) { + const char *parent_snapdir = p - (snapdirlen+1); + + DEBUG(10, ("parent_snapdir = %s\n", parent_snapdir)); + + if (strncmp(parent_snapdir, snapdir, snapdirlen) == 0) { + DEBUG(10, ("name=%s is already converted\n", name)); + goto no_snapshot; + } + } q = strptime(p, GMT_FORMAT, &tm); if (q == NULL) { DEBUG(10, ("strptime failed\n")); -- 2.11.4.GIT