librpc: Return an error if we a broken floor.
[kai/samba.git] / librpc / rpc / binding.c
index 59d508adca34da7ce304c46323db613c3f177b48..422537e1f4ece7b87cde6a4d41349e4d425987c6 100644 (file)
@@ -653,6 +653,15 @@ _PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
        struct dcerpc_binding *binding;
 
+       /*
+        * A tower needs to have at least 4 floors to carry useful
+        * information. Floor 3 is the transport identifier which defines
+        * how many floors are required at least.
+        */
+       if (tower->num_floors < 4) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
        binding = talloc_zero(mem_ctx, struct dcerpc_binding);
        NT_STATUS_HAVE_NO_MEMORY(binding);
 
@@ -669,10 +678,6 @@ _PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
                return NT_STATUS_NOT_SUPPORTED;
        }
 
-       if (tower->num_floors < 1) {
-               return NT_STATUS_OK;
-       }
-
        /* Set object uuid */
        status = dcerpc_floor_get_lhs_data(&tower->floors[0], &binding->object);