The Samba-Bugzilla – Attachment 4290 Details for
Bug 6136
LDAP integer search filters don't handle signed/unsigned 32-bit rollover
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to handle integer 32bit attributes correctly
int32.patch (text/plain), 6.57 KB, created by
Matthias Dieter Wallnöfer
on 2009-06-15 14:58:14 UTC
(
hide
)
Description:
Patch to handle integer 32bit attributes correctly
Filename:
MIME Type:
Creator:
Matthias Dieter Wallnöfer
Created:
2009-06-15 14:58:14 UTC
Size:
6.57 KB
patch
obsolete
>diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c >index d895f09..3330c6c 100644 >--- a/source4/lib/ldb-samba/ldif_handlers.c >+++ b/source4/lib/ldb-samba/ldif_handlers.c >@@ -3,6 +3,7 @@ > > Copyright (C) Andrew Tridgell 2005 > Copyright (C) Andrew Bartlett 2006-2007 >+ Copyright (C) Matthias Dieter Wallnöfer 2009 > ** NOTE! The following LGPL license applies to the ldb > ** library. This does NOT imply that all of Samba is released > ** under the LGPL >@@ -361,7 +362,7 @@ static int ldif_write_ntSecurityDescriptor(struct ldb_context *ldb, void *mem_ct > cn=Person,cn=Schema,cn=Configuration,<basedn> becomes 'person' > */ > >-static int ldif_canonicalise_objectCategory(struct ldb_context *ldb, void *mem_ctx, >+static int ldb_canonicalise_objectCategory(struct ldb_context *ldb, void *mem_ctx, > const struct ldb_val *in, struct ldb_val *out) > { > struct ldb_dn *dn1 = NULL; >@@ -412,7 +413,7 @@ static int ldif_canonicalise_objectCategory(struct ldb_context *ldb, void *mem_c > return LDB_SUCCESS; > } > >-static int ldif_comparison_objectCategory(struct ldb_context *ldb, void *mem_ctx, >+static int ldb_comparison_objectCategory(struct ldb_context *ldb, void *mem_ctx, > const struct ldb_val *v1, > const struct ldb_val *v2) > { >@@ -426,8 +427,8 @@ static int ldif_comparison_objectCategory(struct ldb_context *ldb, void *mem_ctx > * > * It seems easier to continue on the NULL context > */ >- ret1 = ldif_canonicalise_objectCategory(ldb, tmp_ctx, v1, &v1_canon); >- ret2 = ldif_canonicalise_objectCategory(ldb, tmp_ctx, v2, &v2_canon); >+ ret1 = ldb_canonicalise_objectCategory(ldb, tmp_ctx, v1, &v1_canon); >+ ret2 = ldb_canonicalise_objectCategory(ldb, tmp_ctx, v2, &v2_canon); > > if (ret1 == LDB_SUCCESS && ret2 == LDB_SUCCESS) { > ret = data_blob_cmp(&v1_canon, &v2_canon); >@@ -575,7 +576,7 @@ static int ldif_write_prefixMap(struct ldb_context *ldb, void *mem_ctx, > return 0; > } > >-static bool ldif_comparision_prefixMap_isString(const struct ldb_val *v) >+static bool ldb_comparision_prefixMap_isString(const struct ldb_val *v) > { > if (v->length < 4) { > return true; >@@ -591,16 +592,16 @@ static bool ldif_comparision_prefixMap_isString(const struct ldb_val *v) > /* > canonicalise a prefixMap > */ >-static int ldif_canonicalise_prefixMap(struct ldb_context *ldb, void *mem_ctx, >+static int ldb_canonicalise_prefixMap(struct ldb_context *ldb, void *mem_ctx, > const struct ldb_val *in, struct ldb_val *out) > { >- if (ldif_comparision_prefixMap_isString(in)) { >+ if (ldb_comparision_prefixMap_isString(in)) { > return ldif_read_prefixMap(ldb, mem_ctx, in, out); > } > return ldb_handler_copy(ldb, mem_ctx, in, out); > } > >-static int ldif_comparison_prefixMap(struct ldb_context *ldb, void *mem_ctx, >+static int ldb_comparison_prefixMap(struct ldb_context *ldb, void *mem_ctx, > const struct ldb_val *v1, > const struct ldb_val *v2) > { >@@ -614,8 +615,8 @@ static int ldif_comparison_prefixMap(struct ldb_context *ldb, void *mem_ctx, > * > * It seems easier to continue on the NULL context > */ >- ret1 = ldif_canonicalise_prefixMap(ldb, tmp_ctx, v1, &v1_canon); >- ret2 = ldif_canonicalise_prefixMap(ldb, tmp_ctx, v2, &v2_canon); >+ ret1 = ldb_canonicalise_prefixMap(ldb, tmp_ctx, v1, &v1_canon); >+ ret2 = ldb_canonicalise_prefixMap(ldb, tmp_ctx, v2, &v2_canon); > > if (ret1 == LDB_SUCCESS && ret2 == LDB_SUCCESS) { > ret = data_blob_cmp(&v1_canon, &v2_canon); >@@ -626,6 +627,31 @@ static int ldif_comparison_prefixMap(struct ldb_context *ldb, void *mem_ctx, > return ret; > } > >+/* Canonicalisation of two 32-bit integers */ >+static int ldb_canonicalise_int32(struct ldb_context *ldb, void *mem_ctx, >+ const struct ldb_val *in, struct ldb_val *out) >+{ >+ char *end; >+ int32_t i = (int32_t) strtol((char *)in->data, &end, 0); >+ if (*end != 0) { >+ return -1; >+ } >+ out->data = (uint8_t *) talloc_asprintf(mem_ctx, "%d", i); >+ if (out->data == NULL) { >+ return -1; >+ } >+ out->length = strlen((char *)out->data); >+ return 0; >+} >+ >+/* Comparison of two 32-bit integers */ >+static int ldb_comparison_int32(struct ldb_context *ldb, void *mem_ctx, >+ const struct ldb_val *v1, const struct ldb_val *v2) >+{ >+ return (int32_t) strtol((char *)v1->data, NULL, 0) >+ - (int32_t) strtol((char *)v2->data, NULL, 0); >+} >+ > static int extended_dn_write_hex(struct ldb_context *ldb, void *mem_ctx, > const struct ldb_val *in, struct ldb_val *out) > { >@@ -636,11 +662,6 @@ static int extended_dn_write_hex(struct ldb_context *ldb, void *mem_ctx, > return 0; > } > >- >-#define LDB_SYNTAX_SAMBA_GUID "LDB_SYNTAX_SAMBA_GUID" >-#define LDB_SYNTAX_SAMBA_OBJECT_CATEGORY "LDB_SYNTAX_SAMBA_OBJECT_CATEGORY" >-#define LDB_SYNTAX_SAMBA_PREFIX_MAP "LDB_SYNTAX_SAMBA_PREFIX_MAP" >- > static const struct ldb_schema_syntax samba_syntaxes[] = { > { > .name = LDB_SYNTAX_SAMBA_SID, >@@ -664,14 +685,20 @@ static const struct ldb_schema_syntax samba_syntaxes[] = { > .name = LDB_SYNTAX_SAMBA_OBJECT_CATEGORY, > .ldif_read_fn = ldb_handler_copy, > .ldif_write_fn = ldb_handler_copy, >- .canonicalise_fn = ldif_canonicalise_objectCategory, >- .comparison_fn = ldif_comparison_objectCategory >+ .canonicalise_fn = ldb_canonicalise_objectCategory, >+ .comparison_fn = ldb_comparison_objectCategory > },{ > .name = LDB_SYNTAX_SAMBA_PREFIX_MAP, > .ldif_read_fn = ldif_read_prefixMap, > .ldif_write_fn = ldif_write_prefixMap, >- .canonicalise_fn = ldif_canonicalise_prefixMap, >- .comparison_fn = ldif_comparison_prefixMap >+ .canonicalise_fn = ldb_canonicalise_prefixMap, >+ .comparison_fn = ldb_comparison_prefixMap >+ },{ >+ .name = LDB_SYNTAX_SAMBA_INT32, >+ .ldif_read_fn = ldb_handler_copy, >+ .ldif_write_fn = ldb_handler_copy, >+ .canonicalise_fn = ldb_canonicalise_int32, >+ .comparison_fn = ldb_comparison_int32 > } > }; > >@@ -694,6 +721,7 @@ static const struct ldb_dn_extended_syntax samba_dn_syntax[] = { > } > }; > >+/* TODO: Should be dynamic at some point */ > static const struct { > const char *name; > const char *syntax; >diff --git a/source4/lib/ldb-samba/ldif_handlers.h b/source4/lib/ldb-samba/ldif_handlers.h >index e37c416..3e1f17e 100644 >--- a/source4/lib/ldb-samba/ldif_handlers.h >+++ b/source4/lib/ldb-samba/ldif_handlers.h >@@ -3,6 +3,10 @@ > > #define LDB_SYNTAX_SAMBA_SID "LDB_SYNTAX_SAMBA_SID" > #define LDB_SYNTAX_SAMBA_SECURITY_DESCRIPTOR "1.2.840.113556.1.4.907" >+#define LDB_SYNTAX_SAMBA_GUID "LDB_SYNTAX_SAMBA_GUID" >+#define LDB_SYNTAX_SAMBA_OBJECT_CATEGORY "LDB_SYNTAX_SAMBA_OBJECT_CATEGORY" >+#define LDB_SYNTAX_SAMBA_PREFIX_MAP "LDB_SYNTAX_SAMBA_PREFIX_MAP" >+#define LDB_SYNTAX_SAMBA_INT32 "LDB_SYNTAX_SAMBA_INT32" > > #include "lib/ldb-samba/ldif_handlers_proto.h" >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 6136
:
3951
|
3952
|
4282
|
4290
|
4292
|
4300