svn commit: samba r20379 - in branches/SAMBA_4_0/source/dsdb/schema: .

metze at samba.org metze at samba.org
Thu Dec 28 12:49:54 GMT 2006


Author: metze
Date: 2006-12-28 12:49:53 +0000 (Thu, 28 Dec 2006)
New Revision: 20379

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20379

Log:
- make sure the schema info blob is 21 bytes long
- add a function to verify the incoming mapping and schema info

metze
Modified:
   branches/SAMBA_4_0/source/dsdb/schema/schema_init.c


Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/schema/schema_init.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/schema/schema_init.c	2006-12-28 12:17:01 UTC (rev 20378)
+++ branches/SAMBA_4_0/source/dsdb/schema/schema_init.c	2006-12-28 12:49:53 UTC (rev 20379)
@@ -47,6 +47,10 @@
 				return WERR_INVALID_PARAM;
 			}
 
+			if (ctr->mappings[i].oid.__ndr_size != 21) {
+				return WERR_INVALID_PARAM;
+			}
+
 			schema->schema_info = talloc_strdup(schema, ctr->mappings[i].oid.oid);
 			W_ERROR_HAVE_NO_MEMORY(schema->schema_info);
 		} else {
@@ -68,6 +72,66 @@
 	return WERR_OK;
 }
 
+WERROR dsdb_verify_oid_mappings(const struct dsdb_schema *schema, const struct drsuapi_DsReplicaOIDMapping_Ctr *ctr)
+{
+	uint32_t i,j;
+
+	for (i=0; i < ctr->num_mappings; i++) {
+		if (ctr->mappings[i].oid.oid == NULL) {
+			return WERR_INVALID_PARAM;
+		}
+
+		if (strncasecmp(ctr->mappings[i].oid.oid, "ff", 2) == 0) {
+			if (ctr->mappings[i].id_prefix != 0) {
+				return WERR_INVALID_PARAM;
+			}
+
+			/* the magic value should be in the last array member */
+			if (i != (ctr->num_mappings - 1)) {
+				return WERR_INVALID_PARAM;
+			}
+
+			if (ctr->mappings[i].oid.__ndr_size != 21) {
+				return WERR_INVALID_PARAM;
+			}
+
+			if (strcasecmp(schema->schema_info, ctr->mappings[i].oid.oid) != 0) {
+				return WERR_DS_DRA_SCHEMA_MISMATCH;
+			}
+		} else {
+			/* the last array member should contain the magic value not a oid */
+			if (i == (ctr->num_mappings - 1)) {
+				return WERR_INVALID_PARAM;
+			}
+
+			for (j=0; j < schema->num_prefixes; j++) {
+				size_t oid_len;
+				if (schema->prefixes[j].id != (ctr->mappings[i].id_prefix<<16)) {
+					continue;
+				}
+
+				oid_len = strlen(ctr->mappings[i].oid.oid);
+
+				if (oid_len != (schema->prefixes[j].oid_len - 1)) {
+					return WERR_DS_DRA_SCHEMA_MISMATCH;
+				}
+
+				if (strncmp(ctr->mappings[i].oid.oid, schema->prefixes[j].oid, oid_len) != 0) {
+					return WERR_DS_DRA_SCHEMA_MISMATCH;				
+				}
+
+				break;
+			}
+
+			if (j == schema->num_prefixes) {
+				return WERR_DS_DRA_SCHEMA_MISMATCH;				
+			}
+		}
+	}
+
+	return WERR_OK;
+}
+
 WERROR dsdb_map_oid2int(struct dsdb_schema *schema, const char *in, uint32_t *out)
 {
 	uint32_t i;



More information about the samba-cvs mailing list