diff options
author | Jan Engelhardt <jengelh@inai.de> | 2013-02-21 13:12:25 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-02-26 17:18:04 +0100 |
commit | 6072f51a6c91f580c6582c527a08acbe51824d6a (patch) | |
tree | cc9fc0f47853cec6450717b8fba66017c95cb189 /src/db | |
parent | 8bbdf179644bd92ec044b597d62edd9c77453f81 (diff) | |
download | sssd-6072f51a6c91f580c6582c527a08acbe51824d6a.tar.gz sssd-6072f51a6c91f580c6582c527a08acbe51824d6a.tar.xz sssd-6072f51a6c91f580c6582c527a08acbe51824d6a.zip |
sysdb: try dealing with binary-content attributes
https://fedorahosted.org/sssd/ticket/1818
I have here a LDAP user entry which has this attribute
loginAllowedTimeMap::
AAAAAAAAAP///38AAP///38AAP///38AAP///38AAP///38AAAAAAAAA
In the function sysdb_attrs_add_string(), called from
sdap_attrs_add_ldap_attr(), strlen() is called on this blob, which is
the wrong thing to do. The result of strlen is then used to populate
the .v_length member of a struct ldb_val - and this will set it to
zero in this case. (There is also the problem that there may not be
a '\0' at all in the blob.)
Subsequently, .v_length being 0 makes ldb_modify(), called from
sysdb_set_entry_attr(), return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX. End
result is that users do not get stored in the sysdb, and programs like
`id` or `getent ...` show incomplete information.
The bug was encountered with sssd-1.8.5. sssd-1.5.11 seemed to behave
fine, but that may not mean that is the absolute lower boundary of
introduction of the problem.
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/sysdb.c | 10 | ||||
-rw-r--r-- | src/db/sysdb.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c index b0bea9a73..729e10e33 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -511,6 +511,16 @@ int sysdb_attrs_add_string(struct sysdb_attrs *attrs, return sysdb_attrs_add_val(attrs, name, &v); } +int sysdb_attrs_add_mem(struct sysdb_attrs *attrs, const char *name, + const void *mem, size_t size) +{ + struct ldb_val v; + + v.data = discard_const(mem); + v.length = size; + return sysdb_attrs_add_val(attrs, name, &v); +} + int sysdb_attrs_add_bool(struct sysdb_attrs *attrs, const char *name, bool value) { diff --git a/src/db/sysdb.h b/src/db/sysdb.h index db6748cff..8445ebaac 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -280,6 +280,8 @@ int sysdb_attrs_add_val(struct sysdb_attrs *attrs, const char *name, const struct ldb_val *val); int sysdb_attrs_add_string(struct sysdb_attrs *attrs, const char *name, const char *str); +int sysdb_attrs_add_mem(struct sysdb_attrs *, const char *, + const void *, size_t); int sysdb_attrs_add_bool(struct sysdb_attrs *attrs, const char *name, bool value); int sysdb_attrs_add_long(struct sysdb_attrs *attrs, |