# Samba 3.0.20 - findfirst optimization

Jeremy Allison jra at samba.org
Mon Oct 24 18:57:17 GMT 2005

On Mon, Oct 24, 2005 at 10:33:21AM +0200, Dina Fine wrote:
> Hi
>
> I have a question regarding the findfirst optimization  in 3.0.20
> version.
> It seems that it doesn't work if case-sensitive and mangling are
> configured to yes and the path doesn't contain wild chars
>
> If a findfirst request is a mangled file name and the case sensitive is
> configured to yes then the stat in dptr_ReadDirName (line 593, dir.c)
> will fail, and since the case sensitive is yes the function will return
> with NULL in line 616.
> The mangling is not considered here at all.
>
> Am I wrong? Do I miss something?

Ok, I've looked more closely at this - so you're wondering
about a findfirst request ending up (after smbd/filename.c
processing) with a pathname like :

\path\to\dir\MAN~GED.NAM

where the last component is a mangled name ? I don't think
this can happen. The reason is that if the path

\path\to\dir\MAN~GED.NAM

exits, then coming out of the unix_convert() function
the entire pathname will be unmangled. If the path doesn't
exist, then yes the last component of the path will be
left mangled, but then the findfirst should fail anyway
(as the file doesn't exist).

If you have a test case that can show Samba failing under
these circumstances I'd be glad to re-examine this.

Jeremy.