libsmbclient: POLICY_HND not initialized for cached servers

Richard Sharpe rsharpe at
Mon Feb 9 13:38:52 GMT 2004

On Mon, 9 Feb 2004, Lautier, Marc wrote:

> Hi,
> I'm currently working on some customization of the libsmbclient.
> During some tests, I encountered difficulties executing some requests past
> the first one.
> When tracking down the problem, I discovered that the stack "allocated" pol
> variable (of type POLICY_HND), is not properly initialized in function
> smbc_attr_server when the server is retrieved from the server cache.
> This will cause some calls to fail past the first one, especially if the
> stackspace where pol is allocated is overwritten between the calls (so it's
> not necessarily evident by doing a loop to generate lots of calls).
> I could reproduce this issue with a custom testacl.c (from the libsmbclient
> examples)
> Attached is the diff to get a testacl that fails (on the default get
> request, it performs two get, the second one failing to resolve SIDs into
> names properly)
> What is (or should be) the lifecycle of the POLICY_HND here ?
> I see two possible fixes here:
> 	- reinitialize a new POLICY_HND in smbc_attr_server when a server is
> retrieved from the cache.
> 	- cache the POLICY_HND along with the SMBCSRV object, perhaps by
> putting it directly in the SMBCSRV when pertinent (for "IPC$$" servers).

Hmmm, given that policy handles are used by only a few operations, I would 
suggest perhaps that we reinitialize them when a server is retrieved from 
the cache, although if that initialization is expensive, then perhaps we 
should reserve space in the SMBCSRV object.

Richard Sharpe, rsharpe[at], rsharpe[at], 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testacl.diff
Type: application/octet-stream
Size: 890 bytes
Url :

More information about the samba-technical mailing list