s3-epmapper: fix vars init and return errors
authorSimo Sorce <idra@samba.org>
Thu, 24 Mar 2011 15:49:27 +0000 (11:49 -0400)
committerSimo Sorce <idra@samba.org>
Thu, 24 Mar 2011 19:43:49 +0000 (20:43 +0100)
Properly initialize variables at each cycle.
Convert to the right error when returning EPMAPPER ones.

Autobuild-User: Simo Sorce <idra@samba.org>
Autobuild-Date: Thu Mar 24 20:43:49 CET 2011 on sn-devel-104

source3/rpc_server/epmapper/srv_epmapper.c

index b9ddd0583f161d70285d33e1235addf3aae3352f..4fc8ecdeb8e96edb291f348e18f48d9d849b2e14 100644 (file)
@@ -287,6 +287,11 @@ error_status_t _epm_Insert(struct pipes_struct *p,
        error_status_t rc;
        NTSTATUS status;
        uint32_t i;
+       struct dcerpc_binding *b;
+       struct dcesrv_endpoint *ep;
+       struct dcesrv_iface_list *iflist;
+       struct dcesrv_iface *iface;
+       bool add_ep;
 
        /* If this is not a priviledged users, return */
        if (p->transport != NCALRPC ||
@@ -303,19 +308,20 @@ error_status_t _epm_Insert(struct pipes_struct *p,
                  r->in.num_ents));
 
        for (i = 0; i < r->in.num_ents; i++) {
-               struct dcerpc_binding *b = NULL;
-               struct dcesrv_endpoint *ep;
-               struct dcesrv_iface_list *iflist;
-               struct dcesrv_iface *iface;
-               bool add_ep = false;
+               add_ep = false;
+               b = NULL;
 
                status = dcerpc_binding_from_tower(tmp_ctx,
                                                   &r->in.entries[i].tower->tower,
                                                   &b);
-               if (!NT_STATUS_IS_OK(status)) {
+               if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MEMORY)) {
                        rc = EPMAPPER_STATUS_NO_MEMORY;
                        goto done;
                }
+               if (!NT_STATUS_IS_OK(status)) {
+                       rc = EPMAPPER_STATUS_CANT_PERFORM_OP;
+                       goto done;
+               }
 
                DEBUG(3, ("_epm_Insert: Adding transport %s for %s\n",
                          derpc_transport_string_by_transport(b->transport),
@@ -327,7 +333,7 @@ error_status_t _epm_Insert(struct pipes_struct *p,
                        /* No entry found, create it */
                        ep = talloc_zero(NULL, struct dcesrv_endpoint);
                        if (ep == NULL) {
-                               rc = EPMAPPER_STATUS_CANT_PERFORM_OP;
+                               rc = EPMAPPER_STATUS_NO_MEMORY;
                                goto done;
                        }
                        add_ep = true;
@@ -415,6 +421,10 @@ error_status_t _epm_Delete(struct pipes_struct *p,
        error_status_t rc;
        NTSTATUS status;
        uint32_t i;
+       struct dcerpc_binding *b;
+       struct dcesrv_endpoint *ep;
+       struct dcesrv_iface iface;
+       struct dcesrv_iface_list *iflist;
 
        DEBUG(3, ("_epm_Delete: Trying to delete %u entries.\n",
                  r->in.num_ents));
@@ -431,10 +441,7 @@ error_status_t _epm_Delete(struct pipes_struct *p,
        }
 
        for (i = 0; i < r->in.num_ents; i++) {
-               struct dcerpc_binding *b = NULL;
-               struct dcesrv_endpoint *ep;
-               struct dcesrv_iface iface;
-               struct dcesrv_iface_list *iflist;
+               b = NULL;
 
                status = dcerpc_binding_from_tower(tmp_ctx,
                                                   &r->in.entries[i].tower->tower,