1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

s3: VFS: shadow_copy2: Fix a memory leak in the connectpath function.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
This commit is contained in:
Jeremy Allison 2017-01-23 10:06:44 -08:00
parent 128d5f27cd
commit 4d339a8885

View File

@ -78,6 +78,8 @@ struct shadow_copy2_private {
char *shadow_cwd; /* Absolute $cwd path. */
/* Absolute connectpath - can vary depending on $cwd. */
char *shadow_connectpath;
/* malloc'ed realpath return. */
char *shadow_realpath;
};
static int shadow_copy2_get_shadow_copy_data(
@ -2494,6 +2496,13 @@ static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle,
goto done;
}
/*
* SMB_VFS_NEXT_REALPATH returns a malloc'ed string.
* Don't leak memory.
*/
SAFE_FREE(priv->shadow_realpath);
priv->shadow_realpath = result;
DBG_DEBUG("connect path is [%s]\n", result);
done:
@ -2572,6 +2581,12 @@ static int shadow_copy2_get_quota(vfs_handle_struct *handle, const char *path,
return ret;
}
static int shadow_copy2_private_destructor(struct shadow_copy2_private *priv)
{
SAFE_FREE(priv->shadow_realpath);
return 0;
}
static int shadow_copy2_connect(struct vfs_handle_struct *handle,
const char *service, const char *user)
{
@ -2603,6 +2618,8 @@ static int shadow_copy2_connect(struct vfs_handle_struct *handle,
return -1;
}
talloc_set_destructor(priv, shadow_copy2_private_destructor);
priv->snaps = talloc_zero(priv, struct shadow_copy2_snaplist_info);
if (priv->snaps == NULL) {
DBG_ERR("talloc_zero() failed\n");