s4-drs: cope with bogus empty attributes from w2k8-r2
authorAndrew Tridgell <tridge@samba.org>
Sat, 28 Nov 2009 02:27:06 +0000 (13:27 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sat, 28 Nov 2009 02:28:34 +0000 (13:28 +1100)
w2k8-r2 sometimes sends empty attributes with completely bogus attrid
values in a DRS replication response. This allows us to continue with
the vampire operation despite these broken elements.

source4/dsdb/repl/replicated_objects.c

index 020d5f1b0714a7a4e7add1c31230d67c82e6a669..a8a93e413a1b07af1757ffa5227bd29a5f5a41d7 100644 (file)
@@ -129,6 +129,15 @@ static WERROR dsdb_convert_object_ex(struct ldb_context *ldb,
                }
 
                status = dsdb_attribute_drsuapi_to_ldb(ldb, schema, a, msg->elements, e);
+               if (!NT_STATUS_IS_OK(status) && a->value_ctr.num_values == 0) {
+                       /* w2k8-r2 occasionally sends bogus empty
+                          attributes with rubbish attribute IDs. The
+                          only think we can do is discard these */
+                       DEBUG(0,(__location__ ": Discarding bogus empty DsReplicaAttribute with attid 0x%x\n",
+                                a->attid));
+                       ZERO_STRUCTP(e);
+                       continue;
+               }
                W_ERROR_NOT_OK_RETURN(status);
 
                m->attid                        = a->attid;
@@ -149,6 +158,14 @@ static WERROR dsdb_convert_object_ex(struct ldb_context *ldb,
                }
        }
 
+       /* delete any empty elements */
+       for (i=0; i < msg->num_elements; i++) {
+               if (msg->elements[i].name == NULL) {
+                       ldb_msg_remove_element(msg, &msg->elements[i]);
+                       i--;
+               }
+       }
+
        if (rdn_m) {
                struct ldb_message_element *el;
                el = ldb_msg_find_element(msg, rdn_attr->lDAPDisplayName);