s3: VFS: shadow_copy2: Correctly initialize timestamp and stripped variables.
authorJeremy Allison <jra@samba.org>
Fri, 20 Jan 2017 19:42:39 +0000 (11:42 -0800)
committerKarolin Seeger <kseeger@samba.org>
Mon, 13 Feb 2017 15:49:16 +0000 (16:49 +0100)
Allow the called functions to be fixed to not touch them on error.

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>
(cherry picked from commit 0a190f4dd950c947d47c42163d11ea4bd6e6e508)

source3/modules/vfs_shadow_copy2.c

index 1f876e7e104b275bfbd87c27283c36d39d50f9e4..552b1a5518c2d8c2e03c525aeda6e66e7437024e 100644 (file)
@@ -416,10 +416,10 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
                                        char **pstripped)
 {
        struct tm tm;
-       time_t timestamp;
+       time_t timestamp = 0;
        const char *p;
        char *q;
-       char *stripped;
+       char *stripped = NULL;
        size_t rest_len, dst_len;
        struct shadow_copy2_private *priv;
        const char *snapdir;
@@ -893,8 +893,8 @@ static DIR *shadow_copy2_opendir(vfs_handle_struct *handle,
                        const char *mask,
                        uint32_t attr)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        DIR *ret;
        int saved_errno;
        char *conv;
@@ -936,7 +936,8 @@ static int shadow_copy2_rename(vfs_handle_struct *handle,
                               const struct smb_filename *smb_fname_src,
                               const struct smb_filename *smb_fname_dst)
 {
-       time_t timestamp_src, timestamp_dst;
+       time_t timestamp_src = 0;
+       time_t timestamp_dst = 0;
 
        if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
                                         smb_fname_src->base_name,
@@ -962,7 +963,8 @@ static int shadow_copy2_rename(vfs_handle_struct *handle,
 static int shadow_copy2_symlink(vfs_handle_struct *handle,
                                const char *oldname, const char *newname)
 {
-       time_t timestamp_old, timestamp_new;
+       time_t timestamp_old = 0;
+       time_t timestamp_new = 0;
 
        if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
                                         &timestamp_old, NULL)) {
@@ -982,7 +984,8 @@ static int shadow_copy2_symlink(vfs_handle_struct *handle,
 static int shadow_copy2_link(vfs_handle_struct *handle,
                             const char *oldname, const char *newname)
 {
-       time_t timestamp_old, timestamp_new;
+       time_t timestamp_old = 0;
+       time_t timestamp_new = 0;
 
        if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, oldname,
                                         &timestamp_old, NULL)) {
@@ -1002,8 +1005,9 @@ static int shadow_copy2_link(vfs_handle_struct *handle,
 static int shadow_copy2_stat(vfs_handle_struct *handle,
                             struct smb_filename *smb_fname)
 {
-       time_t timestamp;
-       char *stripped, *tmp;
+       time_t timestamp = 0;
+       char *stripped = NULL;
+       char *tmp;
        int ret, saved_errno;
 
        if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
@@ -1041,8 +1045,9 @@ static int shadow_copy2_stat(vfs_handle_struct *handle,
 static int shadow_copy2_lstat(vfs_handle_struct *handle,
                              struct smb_filename *smb_fname)
 {
-       time_t timestamp;
-       char *stripped, *tmp;
+       time_t timestamp = 0;
+       char *stripped = NULL;
+       char *tmp;
        int ret, saved_errno;
 
        if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
@@ -1080,7 +1085,7 @@ static int shadow_copy2_lstat(vfs_handle_struct *handle,
 static int shadow_copy2_fstat(vfs_handle_struct *handle, files_struct *fsp,
                              SMB_STRUCT_STAT *sbuf)
 {
-       time_t timestamp;
+       time_t timestamp = 0;
        int ret;
 
        ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
@@ -1102,8 +1107,9 @@ static int shadow_copy2_open(vfs_handle_struct *handle,
                             struct smb_filename *smb_fname, files_struct *fsp,
                             int flags, mode_t mode)
 {
-       time_t timestamp;
-       char *stripped, *tmp;
+       time_t timestamp = 0;
+       char *stripped = NULL;
+       char *tmp;
        int ret, saved_errno;
 
        if (!shadow_copy2_strip_snapshot(talloc_tos(), handle,
@@ -1138,8 +1144,8 @@ static int shadow_copy2_open(vfs_handle_struct *handle,
 static int shadow_copy2_unlink(vfs_handle_struct *handle,
                               const struct smb_filename *smb_fname)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        struct smb_filename *conv;
 
@@ -1173,7 +1179,7 @@ static int shadow_copy2_chmod(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode)
 {
-       time_t timestamp;
+       time_t timestamp = 0;
        char *stripped = NULL;
        int ret, saved_errno;
        char *conv = NULL;
@@ -1219,8 +1225,8 @@ static int shadow_copy2_chown(vfs_handle_struct *handle,
                        uid_t uid,
                        gid_t gid)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        char *conv = NULL;
        struct smb_filename *conv_smb_fname = NULL;
@@ -1261,8 +1267,8 @@ static int shadow_copy2_chown(vfs_handle_struct *handle,
 static int shadow_copy2_chdir(vfs_handle_struct *handle,
                              const char *fname)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        char *conv;
 
@@ -1289,8 +1295,8 @@ static int shadow_copy2_ntimes(vfs_handle_struct *handle,
                               const struct smb_filename *smb_fname,
                               struct smb_file_time *ft)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        struct smb_filename *conv;
 
@@ -1323,8 +1329,8 @@ static int shadow_copy2_ntimes(vfs_handle_struct *handle,
 static int shadow_copy2_readlink(vfs_handle_struct *handle,
                                 const char *fname, char *buf, size_t bufsiz)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        char *conv;
 
@@ -1350,8 +1356,8 @@ static int shadow_copy2_readlink(vfs_handle_struct *handle,
 static int shadow_copy2_mknod(vfs_handle_struct *handle,
                              const char *fname, mode_t mode, SMB_DEV_T dev)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        char *conv;
 
@@ -1377,7 +1383,7 @@ static int shadow_copy2_mknod(vfs_handle_struct *handle,
 static char *shadow_copy2_realpath(vfs_handle_struct *handle,
                                   const char *fname)
 {
-       time_t timestamp;
+       time_t timestamp = 0;
        char *stripped = NULL;
        char *tmp = NULL;
        char *result = NULL;
@@ -1805,8 +1811,8 @@ static NTSTATUS shadow_copy2_fget_nt_acl(vfs_handle_struct *handle,
                                         TALLOC_CTX *mem_ctx,
                                        struct security_descriptor **ppdesc)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        NTSTATUS status;
        char *conv;
        struct smb_filename *smb_fname = NULL;
@@ -1849,8 +1855,8 @@ static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle,
                                        TALLOC_CTX *mem_ctx,
                                        struct security_descriptor **ppdesc)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        NTSTATUS status;
        char *conv;
        struct smb_filename *conv_smb_fname = NULL;
@@ -1891,8 +1897,8 @@ static int shadow_copy2_mkdir(vfs_handle_struct *handle,
                                const struct smb_filename *smb_fname,
                                mode_t mode)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        char *conv;
        struct smb_filename *conv_smb_fname = NULL;
@@ -1932,8 +1938,8 @@ static int shadow_copy2_mkdir(vfs_handle_struct *handle,
 static int shadow_copy2_rmdir(vfs_handle_struct *handle,
                                const struct smb_filename *smb_fname)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        char *conv;
        struct smb_filename *conv_smb_fname = NULL;
@@ -1973,8 +1979,8 @@ static int shadow_copy2_rmdir(vfs_handle_struct *handle,
 static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
                                unsigned int flags)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        char *conv;
 
@@ -2001,8 +2007,8 @@ static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
                                     const char *fname, const char *aname,
                                     void *value, size_t size)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        ssize_t ret;
        int saved_errno;
        char *conv;
@@ -2031,8 +2037,8 @@ static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle,
                                      const char *fname,
                                      char *list, size_t size)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        ssize_t ret;
        int saved_errno;
        char *conv;
@@ -2059,8 +2065,8 @@ static ssize_t shadow_copy2_listxattr(struct vfs_handle_struct *handle,
 static int shadow_copy2_removexattr(vfs_handle_struct *handle,
                                    const char *fname, const char *aname)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret, saved_errno;
        char *conv;
 
@@ -2088,8 +2094,8 @@ static int shadow_copy2_setxattr(struct vfs_handle_struct *handle,
                                 const char *aname, const void *value,
                                 size_t size, int flags)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        ssize_t ret;
        int saved_errno;
        char *conv;
@@ -2118,8 +2124,8 @@ static int shadow_copy2_chmod_acl(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        ssize_t ret;
        int saved_errno;
        char *conv = NULL;
@@ -2164,8 +2170,8 @@ static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
                                          TALLOC_CTX *mem_ctx,
                                          char **found_name)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        ssize_t ret;
        int saved_errno;
        char *conv;
@@ -2203,7 +2209,7 @@ static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
 static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle,
                                            const char *fname)
 {
-       time_t timestamp;
+       time_t timestamp = 0;
        char *stripped = NULL;
        char *tmp = NULL;
        char *result = NULL;
@@ -2278,8 +2284,8 @@ static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
                                       const char *path, uint64_t *bsize,
                                       uint64_t *dfree, uint64_t *dsize)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        ssize_t ret;
        int saved_errno;
        char *conv;
@@ -2312,8 +2318,8 @@ static int shadow_copy2_get_quota(vfs_handle_struct *handle, const char *path,
                                  enum SMB_QUOTA_TYPE qtype, unid_t id,
                                  SMB_DISK_QUOTA *dq)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret;
        int saved_errno;
        char *conv;