librpc/rpc: use dcerpc_binding_get_*() in dcerpc_default_transport_endpoint()
authorStefan Metzmacher <metze@samba.org>
Thu, 30 Jan 2014 08:09:04 +0000 (09:09 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 13 Feb 2014 10:54:15 +0000 (11:54 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
librpc/rpc/dcerpc_util.c

index 56eff034b37771a901c73fbb3979500521025fc0..792848fbd916a582f7d68ccba2d8c6aafe168bda 100644 (file)
@@ -354,24 +354,37 @@ const char *dcerpc_default_transport_endpoint(TALLOC_CTX *mem_ctx,
        /* Find one of the default pipes for this interface */
 
        for (i = 0; i < table->endpoints->count; i++) {
+               enum dcerpc_transport_t dtransport;
+               const char *dendpoint;
 
                status = dcerpc_parse_binding(frame, table->endpoints->names[i],
                                              &default_binding);
-               if (NT_STATUS_IS_OK(status)) {
-                       if (transport == NCA_UNKNOWN &&
-                           default_binding->endpoint != NULL) {
-                               p = default_binding->endpoint;
-                               break;
-                       }
-                       if (default_binding->transport == transport &&
-                           default_binding->endpoint != NULL) {
-                               p = default_binding->endpoint;
-                               break;
-                       }
+               if (!NT_STATUS_IS_OK(status)) {
+                       continue;
+               }
+
+               dtransport = dcerpc_binding_get_transport(default_binding);
+               dendpoint = dcerpc_binding_get_string_option(default_binding,
+                                                            "endpoint");
+               if (dendpoint == NULL) {
+                       TALLOC_FREE(default_binding);
+                       continue;
                }
+
+               if (transport == NCA_UNKNOWN) {
+                       transport = dtransport;
+               }
+
+               if (transport != dtransport) {
+                       TALLOC_FREE(default_binding);
+                       continue;
+               }
+
+               p = dendpoint;
+               break;
        }
 
-       if (i == table->endpoints->count || p == NULL) {
+       if (p == NULL) {
                goto done;
        }
 
@@ -379,7 +392,7 @@ const char *dcerpc_default_transport_endpoint(TALLOC_CTX *mem_ctx,
         * extract the pipe name without \\pipe from for example
         * ncacn_np:[\\pipe\\epmapper]
         */
-       if (default_binding->transport == NCACN_NP) {
+       if (transport == NCACN_NP) {
                if (strncasecmp(p, "\\pipe\\", 6) == 0) {
                        p += 6;
                }