diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-09-29 18:57:01 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2010-01-13 16:03:54 +0100 |
commit | ece3defd15246f232acaf0c2c29b66da2924438a (patch) | |
tree | 4894853a525093a02d15eeac53a0940002e2f58b /source4/dsdb/schema | |
parent | a0f2a49b8a67a60c2ecc188043848140a3e944c2 (diff) | |
download | samba-ece3defd15246f232acaf0c2c29b66da2924438a.tar.gz samba-ece3defd15246f232acaf0c2c29b66da2924438a.tar.bz2 samba-ece3defd15246f232acaf0c2c29b66da2924438a.zip |
s4:dsdb/schema: add dsdb_syntax_INT32_validate_ldb()
metze
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r-- | source4/dsdb/schema/schema_syntax.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c index 1399d2fe15..bb78ab391d 100644 --- a/source4/dsdb/schema/schema_syntax.c +++ b/source4/dsdb/schema/schema_syntax.c @@ -293,6 +293,53 @@ static WERROR dsdb_syntax_INT32_ldb_to_drsuapi(struct ldb_context *ldb, return WERR_OK; } +static WERROR dsdb_syntax_INT32_validate_ldb(struct ldb_context *ldb, + const struct dsdb_schema *schema, + const struct dsdb_attribute *attr, + const struct ldb_message_element *in) +{ + uint32_t i; + + if (attr->attributeID_id == 0xFFFFFFFF) { + return WERR_FOOBAR; + } + + for (i=0; i < in->num_values; i++) { + long v; + char buf[sizeof("-2147483648")]; + char *end = NULL; + + ZERO_STRUCT(buf); + if (in->values[i].length >= sizeof(buf)) { + return WERR_DS_INVALID_ATTRIBUTE_SYNTAX; + } + + memcpy(buf, in->values[i].data, in->values[i].length); + errno = 0; + v = strtol(buf, &end, 10); + if (errno != 0) { + return WERR_DS_INVALID_ATTRIBUTE_SYNTAX; + } + if (end && end[0] != '\0') { + return WERR_DS_INVALID_ATTRIBUTE_SYNTAX; + } + + if (attr->rangeLower) { + if ((int32_t)v < (int32_t)*attr->rangeLower) { + return WERR_DS_INVALID_ATTRIBUTE_SYNTAX; + } + } + + if (attr->rangeUpper) { + if ((int32_t)v > (int32_t)*attr->rangeUpper) { + return WERR_DS_INVALID_ATTRIBUTE_SYNTAX; + } + } + } + + return WERR_OK; +} + static WERROR dsdb_syntax_INT64_drsuapi_to_ldb(struct ldb_context *ldb, const struct dsdb_schema *schema, const struct dsdb_attribute *attr, @@ -1664,7 +1711,7 @@ static const struct dsdb_syntax dsdb_syntaxes[] = { .attributeSyntax_oid = "2.5.5.9", .drsuapi_to_ldb = dsdb_syntax_INT32_drsuapi_to_ldb, .ldb_to_drsuapi = dsdb_syntax_INT32_ldb_to_drsuapi, - .validate_ldb = dsdb_syntax_ALLOW_validate_ldb, + .validate_ldb = dsdb_syntax_INT32_validate_ldb, .equality = "integerMatch", .comment = "Integer", .ldb_syntax = LDB_SYNTAX_SAMBA_INT32 |