s4:dsdb/common/util.c - describe the behaviour of the functions "samdb_msg_add_uint...
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 16 Oct 2010 08:36:32 +0000 (10:36 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 16 Oct 2010 08:42:21 +0000 (10:42 +0200)
Unsigned int data in AD is a bit problematic to handle. Problem described by
abartlet.

source4/dsdb/common/util.c

index 1d28771a5f0cd477a0f2f0469338620c556521a8..9e6ccbc9114a2e8e88451e635a3568ffd898a591 100644 (file)
@@ -933,8 +933,17 @@ int samdb_msg_add_int(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct l
 }
 
 /*
-  add a unsigned int element to a message
-*/
+ * Add an unsigned int element to a message
+ *
+ * The issue here is that we have not yet first cast to int32_t explicitly,
+ * before we cast to an signed int to printf() into the %d or cast to a
+ * int64_t before we then cast to a long long to printf into a %lld.
+ *
+ * There are *no* unsigned integers in Active Directory LDAP, even the RID
+ * allocations and ms-DS-Secondary-KrbTgt-Number are *signed* quantities.
+ * (See the schema, and the syntax definitions in schema_syntax.c).
+ *
+ */
 int samdb_msg_add_uint(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
                       const char *attr_name, unsigned int v)
 {
@@ -955,8 +964,17 @@ int samdb_msg_add_int64(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct
 }
 
 /*
-  add a uint64_t element to a message
-*/
+ * Add an unsigned int64_t (uint64_t) element to a message
+ *
+ * The issue here is that we have not yet first cast to int32_t explicitly,
+ * before we cast to an signed int to printf() into the %d or cast to a
+ * int64_t before we then cast to a long long to printf into a %lld.
+ *
+ * There are *no* unsigned integers in Active Directory LDAP, even the RID
+ * allocations and ms-DS-Secondary-KrbTgt-Number are *signed* quantities.
+ * (See the schema, and the syntax definitions in schema_syntax.c).
+ *
+ */
 int samdb_msg_add_uint64(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
                        const char *attr_name, uint64_t v)
 {
@@ -1078,7 +1096,16 @@ int samdb_msg_set_int(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx,
 }
 
 /*
- * sets an unsigned integer in a message
+ * Sets an unsigned int element in a message
+ *
+ * The issue here is that we have not yet first cast to int32_t explicitly,
+ * before we cast to an signed int to printf() into the %d or cast to a
+ * int64_t before we then cast to a long long to printf into a %lld.
+ *
+ * There are *no* unsigned integers in Active Directory LDAP, even the RID
+ * allocations and ms-DS-Secondary-KrbTgt-Number are *signed* quantities.
+ * (See the schema, and the syntax definitions in schema_syntax.c).
+ *
  */
 int samdb_msg_set_uint(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx,
                       struct ldb_message *msg, const char *attr_name,