diff options
author | Kamen Mazdrashki <kamenim@samba.org> | 2010-09-17 02:37:46 +0300 |
---|---|---|
committer | Kamen Mazdrashki <kamenim@samba.org> | 2010-09-17 13:53:03 +0300 |
commit | e691b1fd276bbf26961a23a5c450e96f16da5d4e (patch) | |
tree | 9de73aee84b607466d53cc5799fa7f7cc69870e2 | |
parent | c79861a14e671ea037f550dbf5c2ae9e84fb3803 (diff) | |
download | samba-e691b1fd276bbf26961a23a5c450e96f16da5d4e.tar.gz samba-e691b1fd276bbf26961a23a5c450e96f16da5d4e.tar.bz2 samba-e691b1fd276bbf26961a23a5c450e96f16da5d4e.zip |
s4-dsdb: Add dsdb_schema_info_blob_is_valid() to verify schemaInfo blobls
-rw-r--r-- | source4/dsdb/schema/schema_info_attr.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/source4/dsdb/schema/schema_info_attr.c b/source4/dsdb/schema/schema_info_attr.c index a9c5e932a1..fb93d91f35 100644 --- a/source4/dsdb/schema/schema_info_attr.c +++ b/source4/dsdb/schema/schema_info_attr.c @@ -70,6 +70,28 @@ WERROR dsdb_schema_info_blob_new(TALLOC_CTX *mem_ctx, DATA_BLOB *_schema_info_bl /** + * Verify the 'blob' is a valid schemaInfo blob + */ +bool dsdb_schema_info_blob_is_valid(const DATA_BLOB *blob) +{ + if (!blob || !blob->data) { + return false; + } + + /* schemaInfo blob must be 21 bytes long */ + if (blob->length != 21) { + return false; + } + + /* schemaInfo blob should start with 0xFF */ + if (blob->data[0] != 0xFF) { + return false; + } + + return true; +} + +/** * Parse schemaInfo structure from a data_blob * (DATA_BLOB or ldb_val). * Suitable for parsing blobs that comes from @@ -83,16 +105,8 @@ WERROR dsdb_schema_info_from_blob(const DATA_BLOB *blob, struct dsdb_schema_info *schema_info; struct schemaInfoBlob schema_info_blob; - if (!blob || !blob->data) { - return WERR_INVALID_PARAMETER; - } - - if (blob->length != 21) { - return WERR_INVALID_PARAMETER; - } - - /* schemaInfo blob should start with 0xFF */ - if (blob->data[0] != 0xFF) { + /* verify schemaInfo blob is valid */ + if (!dsdb_schema_info_blob_is_valid(blob)) { return WERR_INVALID_PARAMETER; } |