s4-drs: Implement constraints on ATTID values in prefixMap
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>
Fri, 18 Dec 2009 23:49:31 +0000 (01:49 +0200)
committerAndrew Tridgell <tridge@samba.org>
Mon, 21 Dec 2009 12:45:18 +0000 (23:45 +1100)
Ref: MS-ADTS, 3.1.1.2.6 ATTRTYP

Signed-off-by: Andrew Tridgell <tridge@samba.org>
source4/dsdb/schema/prefixmap.h
source4/dsdb/schema/schema_prefixmap.c

index 816ddcfbb39695f0ebf25a01e5872e09f27d4543..74acecb4ffb58fa2755084845a6353f8341306b1 100644 (file)
 #ifndef _DSDB_PREFIXMAP_H
 #define _DSDB_PREFIXMAP_H
 
+/**
+ * ATTRTYP ranges
+ * Ref: MS-ADTS, 3.1.1.2.6 ATTRTYP
+ */
+enum dsdb_attid_type {
+       dsdb_attid_type_pfm = 1,        /* attid in [0x00000000..0x7FFFFFFF] */
+       dsdb_attid_type_intid = 2,      /* attid in [0x80000000..0xBFFFFFFF] */
+       dsdb_attid_type_reserved = 3,   /* attid in [0xC0000000..0xFFFEFFFF] */
+       dsdb_attid_type_internal = 4,   /* attid in [0xFFFF0000..0xFFFFFFFF] */
+};
+
 /**
  * oid-prefix in prefixmap
  */
index 969b357a399588e213fc20faa2ac2e311e69d054..89d33779e4b7d1fa891e49cd05981c3d092b09c0 100644 (file)
 #include "../lib/util/asn1.h"
 
 
+/**
+ * Determine range type for supplied ATTID
+ */
+enum dsdb_attid_type dsdb_pfm_get_attid_type(uint32_t attid)
+{
+       if (attid <= 0x7FFFFFFF) {
+               return dsdb_attid_type_pfm;
+       }
+       else if (attid <= 0xBFFFFFFF) {
+               return dsdb_attid_type_intid;
+       }
+       else if (attid <= 0xFFFEFFFF) {
+               return dsdb_attid_type_reserved;
+       }
+       else {
+               return dsdb_attid_type_internal;
+       }
+}
+
 /**
  * Allocates schema_prefixMap object in supplied memory context
  */
@@ -303,6 +322,11 @@ WERROR dsdb_schema_pfm_oid_from_attid(struct dsdb_schema_prefixmap *pfm, uint32_
        struct dsdb_schema_prefixmap_oid *pfm_entry;
        WERROR werr = WERR_OK;
 
+       /* sanity check for attid requested */
+       if (dsdb_pfm_get_attid_type(attid) != dsdb_attid_type_pfm) {
+               return WERR_INVALID_PARAMETER;
+       }
+
        /* crack attid value */
        hi_word = attid >> 16;
        lo_word = attid & 0xFFFF;