s3: Don't copy back the stat struct from stat_cache_lookup if we did not get a hit...
authorRichard Sharpe <richard.sharpe@primarydata.com>
Mon, 17 Sep 2018 22:38:06 +0000 (15:38 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 19 Sep 2018 15:52:13 +0000 (17:52 +0200)
Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/statcache.c

index 27f9dec48f76bb26b88196d7cd10ebf0492f4838..5162ec06ea9c744cde5021d3fd91cad44cb928ca 100644 (file)
@@ -261,10 +261,7 @@ bool stat_cache_lookup(connection_struct *conn,
                 * Count the number of times we have done this, we'll
                 * need it when reconstructing the string.
                 */
-
-               if (sizechanged) {
-                       num_components++;
-               }
+               num_components++;
 
                if ((*chk_name == '\0')
                    || ISDOT(chk_name) || ISDOTDOT(chk_name)) {
@@ -301,7 +298,12 @@ bool stat_cache_lookup(connection_struct *conn,
                TALLOC_FREE(translated_path);
                return False;
        }
-       *pst = smb_fname.st;
+       /*
+        * Only copy the stat struct back if we actually hit the full path
+        */
+       if (num_components == 0) {
+               *pst = smb_fname.st;
+       }
 
        if (!sizechanged) {
                memcpy(*pp_name, translated_path,