summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-03-15 05:24:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:57:21 -0500
commit66fe18750ce0676749dd982801e74e87deb08264 (patch)
treea96d9f8695040fccbc62e9e671c9d37f62735dcc /source4/dsdb
parentcd9532818340094ef05928c26366830f243169d5 (diff)
downloadsamba-66fe18750ce0676749dd982801e74e87deb08264.tar.gz
samba-66fe18750ce0676749dd982801e74e87deb08264.tar.bz2
samba-66fe18750ce0676749dd982801e74e87deb08264.zip
r14422: ensure that domain_attrs does not refer to a stack variable in a freed
stack frame. The previous code worked with gcc, but strictly speaking the arrays are out of scope when referenced later in the function, and a compiler could construct them on the fly on the stack. (This used to be commit 489c33806559d0a8ee2bec97fed8ad63a4e1dc17)
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/cracknames.c65
1 files changed, 30 insertions, 35 deletions
diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c
index 889995ecb5..af3fdd8926 100644
--- a/source4/dsdb/samdb/cracknames.c
+++ b/source4/dsdb/samdb/cracknames.c
@@ -577,49 +577,44 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_
struct ldb_message **result_res = NULL;
const struct ldb_dn *result_basedn;
+ const char * const _domain_attrs_1779[] = { "ncName", "dnsRoot", NULL};
+ const char * const _result_attrs_null[] = { NULL };
+
+ const char * const _domain_attrs_canonical[] = { "ncName", "dnsRoot", NULL};
+ const char * const _result_attrs_canonical[] = { "canonicalName", NULL };
+
+ const char * const _domain_attrs_nt4[] = { "ncName", "dnsRoot", "nETBIOSName", NULL};
+ const char * const _result_attrs_nt4[] = { "sAMAccountName", "objectSid", NULL};
+
+ const char * const _domain_attrs_guid[] = { "ncName", "dnsRoot", NULL};
+ const char * const _result_attrs_guid[] = { "objectGUID", NULL};
+
+ const char * const _domain_attrs_display[] = { "ncName", "dnsRoot", NULL};
+ const char * const _result_attrs_display[] = { "displayName", "samAccountName", NULL};
+
/* here we need to set the attrs lists for domain and result lookups */
switch (format_desired) {
case DRSUAPI_DS_NAME_FORMAT_FQDN_1779:
- case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX: {
- const char * const _domain_attrs[] = { "ncName", "dnsRoot", NULL};
- const char * const _result_attrs[] = { NULL};
-
- domain_attrs = _domain_attrs;
- result_attrs = _result_attrs;
+ case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX:
+ domain_attrs = _domain_attrs_1779;
+ result_attrs = _result_attrs_null;
break;
- }
- case DRSUAPI_DS_NAME_FORMAT_CANONICAL: {
- const char * const _domain_attrs[] = { "ncName", "dnsRoot", NULL};
- const char * const _result_attrs[] = { "canonicalName", NULL };
-
- domain_attrs = _domain_attrs;
- result_attrs = _result_attrs;
+ case DRSUAPI_DS_NAME_FORMAT_CANONICAL:
+ domain_attrs = _domain_attrs_canonical;
+ result_attrs = _result_attrs_canonical;
break;
- }
- case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT: {
- const char * const _domain_attrs[] = { "ncName", "dnsRoot", "nETBIOSName", NULL};
- const char * const _result_attrs[] = { "sAMAccountName", "objectSid", NULL};
-
- domain_attrs = _domain_attrs;
- result_attrs = _result_attrs;
+ case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT:
+ domain_attrs = _domain_attrs_nt4;
+ result_attrs = _result_attrs_nt4;
break;
- }
- case DRSUAPI_DS_NAME_FORMAT_GUID: {
- const char * const _domain_attrs[] = { "ncName", "dnsRoot", NULL};
- const char * const _result_attrs[] = { "objectGUID", NULL};
-
- domain_attrs = _domain_attrs;
- result_attrs = _result_attrs;
+ case DRSUAPI_DS_NAME_FORMAT_GUID:
+ domain_attrs = _domain_attrs_guid;
+ result_attrs = _result_attrs_guid;
break;
- }
- case DRSUAPI_DS_NAME_FORMAT_DISPLAY: {
- const char * const _domain_attrs[] = { "ncName", "dnsRoot", NULL};
- const char * const _result_attrs[] = { "displayName", "samAccountName", NULL};
-
- domain_attrs = _domain_attrs;
- result_attrs = _result_attrs;
+ case DRSUAPI_DS_NAME_FORMAT_DISPLAY:
+ domain_attrs = _domain_attrs_display;
+ result_attrs = _result_attrs_display;
break;
- }
default:
return WERR_OK;
}