diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-12-28 12:49:53 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:30:20 -0500 |
commit | 58388f70907be71280e712f271c7596474efeacf (patch) | |
tree | a3f74a5bc1915ec46a66739bd2a1ba1829f09f24 | |
parent | 11018b0e134bee5bd7f7680114343e9f17f529e1 (diff) | |
download | samba-58388f70907be71280e712f271c7596474efeacf.tar.gz samba-58388f70907be71280e712f271c7596474efeacf.tar.bz2 samba-58388f70907be71280e712f271c7596474efeacf.zip |
r20379: - make sure the schema info blob is 21 bytes long
- add a function to verify the incoming mapping and schema info
metze
(This used to be commit 5f0da4a3ae4eae8a6f14f813a65583cef78e73e4)
-rw-r--r-- | source4/dsdb/schema/schema_init.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index 59ab62eb92..eff7a3c185 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -47,6 +47,10 @@ WERROR dsdb_load_oid_mappings(struct dsdb_schema *schema, const struct drsuapi_D 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 @@ WERROR dsdb_load_oid_mappings(struct dsdb_schema *schema, const struct drsuapi_D 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; |