r616: Bug #1333.
authorRichard Sharpe <sharpe@samba.org>
Sun, 9 May 2004 17:29:09 +0000 (17:29 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:51:31 +0000 (10:51 -0500)
Make sure we return an error code when things go wrong.
(This used to be commit 21cdb45b54662c7835aea1d16fdd5902cf7a7496)

source3/libsmb/libsmbclient.c

index 417b5ba8d4d4c279791da1081fc8e8fd3a36eb05..949c5ffab670f0ec1b928a2df922e2fddf04be9b 100644 (file)
@@ -680,12 +680,18 @@ SMBCSRV *smbc_server(SMBCCTX *context,
        srv->cli = c;
        srv->dev = (dev_t)(str_checksum(server) ^ str_checksum(share));
 
-       /* now add it to the cache (internal or external) */
+       /* now add it to the cache (internal or external)  */
+       /* Let the cache function set errno if it wants to */
+       errno = 0;
        if (context->callbacks.add_cached_srv_fn(context, srv, server, share, workgroup, username)) {
+               int saved_errno = errno;
                DEBUG(3, (" Failed to add server to cache\n"));
+               saved_errno = errno;
+               if (errno == 0) {
+                       errno = ENOMEM;
+               }
                goto failed;
        }
-
        
        DEBUG(2, ("Server connect ok: //%s/%s: %p\n", 
                  server, share, srv));