From e6b353e7640dcc98cd6d519cee1d5ff42e8c676f Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 2 Jul 2005 18:34:13 +0000 Subject: r8083: check attribute type is valid (only ascii alphanum chars and '-' char) fail if not (This used to be commit b1a61cd5d03b4c61b81c810123ffeb3621831617) --- source4/lib/ldb/common/ldb_dn.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source4/lib/ldb/common') diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index 18b620b506..8b9cf4e129 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -41,6 +41,21 @@ #define LDB_DN_NULL_FAILED(x) if (!(x)) goto failed +static int ldb_dn_is_valid_attribute_name(const char *name) +{ + while (*name) { + if (! isascii(*name)) { + return 0; + } + if (! (isalnum(*name) || *name == '-')) { + return 0; + } + name++; + } + + return 1; +} + static char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value) { const char *p, *s, *src; @@ -250,6 +265,10 @@ static struct ldb_dn_component ldb_dn_explode_component(void *mem_ctx, char *raw if (!dc.name) return dc; + if (! ldb_dn_is_valid_attribute_name(dc.name)) { + goto failed; + } + ret = get_quotes_position(p, &qs, &qe); switch (ret) { -- cgit