smbcli_full_connection fails with NT_STATUS_NO_MEMORY when socket not connected?

Richard Sharpe realrichardsharpe at
Sun Apr 8 11:09:00 MDT 2012

Hi folks,

Yesterday I encountered a curious problem. I did not have smbd running
and I started getting errors from pysmb.c saying Memory Allocation

I have tracked it down to the following:

smbXcli_conn_create calls getpeername on an unconnected socket and
gets an error. It returns a NULL connection. (So, now the reason for
the failure is lost and has been turned into essentially ENOMEM,
although perhaps this is too late anyway.)

That causes smbcli_transport_init to return a NULL transport.

source4/libcli/smb_composite/connect.c:connect_send_negprot returns

This seems wrong and seems to have been caused by overloading a NULL
return to mean: There was an error, but I am confused about what it

How do we fix this? My initial suggestion is that all functions should
return an NTSTATUS or an errno, but that seems like a lot of code to
check. Perhaps we can test earlier in the process of composite
handling for an actually connected socket rather than allowing it to
get so far into the process?

Richard Sharpe

More information about the samba-technical mailing list