[PATCH] Fix fresh Coverity defects

Jeremy Allison jra at samba.org
Thu Jan 7 23:44:41 UTC 2016


On Thu, Jan 07, 2016 at 09:48:42PM +0100, Volker Lendecke wrote:
> Hi, Jeremy!
> 
> Pinging you directly for the last of the patches. This is a
> bit tricky and from a new code path. Please take a look, I
> don't 100% get the semantics of us restoring
> smb_fname->base_name in the fail: case for the "stream of
> rootdir" code.
> 
> Thanks for some review!

Actually, I think the diff below would also do the
trick:

But I actually like your fix better (with the name
of the variable null changed to cnull, as null might
be the kind of #define that some strange included header
might define somewhere :-).

Your fix removes the problem once and for all, and
means calling 'goto done' anywhere before 'start'
gets used is safe. Nice fixes - pushed - thanks !

Jeremy.

-----------------------------------------------------------
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index c2ed1fc..177459f 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -360,6 +360,8 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                }
        }
 
+       start = smb_fname->base_name;
+
        /*
         * Strip off the stream, and add it back when we're done with the
         * base_name.
@@ -406,13 +408,13 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                                DEBUG(5, ("conversion finished %s -> %s\n",
                                        orig_path,
                                        smb_fname->base_name));
+
+                               start = smb_fname->base_name;
                                goto done;
                        }
                }
        }
 
-       start = smb_fname->base_name;
-
        /*
         * If we're providing case insensitive semantics or
         * the underlying filesystem is case insensitive,



More information about the samba-technical mailing list