From 0ce1612f02a9e348e234dcdb20858fb6db11c785 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 11 Dec 2013 09:41:38 +0100 Subject: [PATCH] shadow_copy2: add a comment explaining why we don't talloc_zero_array(). Since I stumbled over this slighly sublte point, I thought it is worthwile to point it our in a comment. Signed-off-by: Michael Adam Reviewed-by: Andreas Schneider Autobuild-User(master): Michael Adam Autobuild-Date(master): Wed Dec 11 19:55:20 CET 2013 on sn-devel-104 (cherry picked from commit 27baff0ec96cded0446ecd7739e9d31aaeb90868) The last 36 patches address bug #10259 - shadow_copy2 module "Previous Version" not working in Windows 7. Autobuild-User(v4-0-test): Karolin Seeger Autobuild-Date(v4-0-test): Mon Jan 13 12:13:18 CET 2014 on sn-devel-104 --- source3/modules/vfs_shadow_copy2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 5856ea9b251..8964c22ac1c 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -482,6 +482,15 @@ static char *shadow_copy2_convert(TALLOC_CTX *mem_ctx, } insertlen = talloc_get_size(insert)-1; + /* + * Note: We deliberatly don't expensively initialize the + * array with talloc_zero here: Putting zero into + * converted[pathlen+insertlen] below is sufficient, because + * in the following for loop, the insert string is inserted + * at various slash places. So the memory up to position + * pathlen+insertlen will always be initialized when the + * converted string is used. + */ converted = talloc_array(mem_ctx, char, pathlen + insertlen + 1); if (converted == NULL) { goto fail; -- 2.11.4.GIT