diff options
| author | Kamen Mazdrashki <kamenim@samba.org> | 2014-11-11 02:56:32 +0100 |
|---|---|---|
| committer | Andrew Bartlett <abartlet@samba.org> | 2014-11-25 05:04:07 +0100 |
| commit | ea7778697e22ffbe22634974144c6e5c142a85d6 (patch) | |
| tree | 0de585d7fe58dd2b3b9f54977ffc907d7b5cfca0 /lib/ldb/common | |
| parent | 4d25dfd611e7786a17975fcaed039be971bac7da (diff) | |
| download | samba-ea7778697e22ffbe22634974144c6e5c142a85d6.tar.gz samba-ea7778697e22ffbe22634974144c6e5c142a85d6.tar.xz samba-ea7778697e22ffbe22634974144c6e5c142a85d6.zip | |
lib-ldb: Check for input parameter when searching attributes by name
This prevents a segfault that is hard to be tracked down from
Python bindings for instance.
Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/ldb/common')
| -rw-r--r-- | lib/ldb/common/ldb_attributes.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/ldb/common/ldb_attributes.c b/lib/ldb/common/ldb_attributes.c index 21a3e6eb93..767f69cdbb 100644 --- a/lib/ldb/common/ldb_attributes.c +++ b/lib/ldb/common/ldb_attributes.c @@ -116,8 +116,14 @@ static const struct ldb_schema_attribute ldb_attribute_default = { }; /* - return the attribute handlers for a given attribute -*/ + * Return the attribute handlers for a given attribute + * + * @param ldb ldb context + * @param name attribute name to search for + * @return Always return valid pointer to schema attribute. + * In case there is no attribute with name, + * ldb_attribute_default is returned + */ static const struct ldb_schema_attribute *ldb_schema_attribute_by_name_internal( struct ldb_context *ldb, const char *name) @@ -127,6 +133,11 @@ static const struct ldb_schema_attribute *ldb_schema_attribute_by_name_internal( int r; const struct ldb_schema_attribute *def = &ldb_attribute_default; + /* fallback to default attribute implementation */ + if (name == NULL) { + return def; + } + /* as handlers are sorted, '*' must be the first if present */ if (strcmp(ldb->schema.attributes[0].name, "*") == 0) { def = &ldb->schema.attributes[0]; |
