From: Kurt Zeilenga Date: Thu, 18 Apr 2002 19:28:26 +0000 (+0000) Subject: Blind commit: X-Git-Tag: OPENLDAP_REL_ENG_2_MP~167 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=96eda541e95247c48ca17b3f9e7b053feab3f80b;p=openldap Blind commit: Re: Untested patch: back-tcl used wrong types (ITS#1719) ================ Written by Hallvard B. Furuseth and placed into the public domain. This software is not subject to any license of the University of Oslo. ================ > I turned it into an automatic variable. ...and used a variable-length array. That's a gcc extension, it is not in ANSI C89. (It is in C99 though.) You seem to be compiling without -pedantic:-) Anyway, here is a patch to turn it back into ch_malloc(), plus some README fixes --- diff --git a/servers/slapd/back-tcl/README.back-tcl b/servers/slapd/back-tcl/README.back-tcl index b7b890be56..66d53e77c6 100644 --- a/servers/slapd/back-tcl/README.back-tcl +++ b/servers/slapd/back-tcl/README.back-tcl @@ -25,7 +25,7 @@ compare abandon # This is one of the biggest pluses of using the tcl backend. -# The realm let's you group several databases to the same interpreter. +# The realm lets you group several databases to the same interpreter. # This basically means they share the same global variables and proc # space. So global variables, as well as all the procs, are callable # between databases. If no tclrealm is specified, it is put into the @@ -109,7 +109,7 @@ modrdn { action msgid suffix dn newrdn deleteoldrdn } msgid - The msgid of this ldap session suffix - List of suffix(es) associated with the call. Each one is and entry in a tcl formatted list (surrounded by {}'s) - dn - DN who's RDN is being renamed + dn - DN whose RDN is being renamed newrdn - New RDN deleteoldrdn - Boolean stating whether or not the old RDN should be removed after being renamed diff --git a/servers/slapd/back-tcl/tcl_search.c b/servers/slapd/back-tcl/tcl_search.c index b4c886e764..f9944a56d3 100644 --- a/servers/slapd/back-tcl/tcl_search.c +++ b/servers/slapd/back-tcl/tcl_search.c @@ -47,12 +47,12 @@ tcl_back_search ( for (i = 0, an = attrs; an && an->an_name.bv_val; an++, i++); if (i > 0) { - char *sattrs[i+1]; - + char **sattrs = ch_malloc( (i+1) * sizeof(char *)); for (i = 0, an = attrs; an->an_name.bv_val; an++, i++) sattrs[i] = an->an_name.bv_val; sattrs[i] = NULL; attrs_tcl = Tcl_Merge (i, sattrs); + ch_free(sattrs); } if (tcl_merge_bvlist (be->be_suffix, &suf_tcl) == NULL) { diff --git a/servers/slapd/back-tcl/tcl_util.c b/servers/slapd/back-tcl/tcl_util.c index f7cddf0204..5d197f36bc 100644 --- a/servers/slapd/back-tcl/tcl_util.c +++ b/servers/slapd/back-tcl/tcl_util.c @@ -215,13 +215,19 @@ tcl_merge_bvlist( for (i = 0; bvlist[i] != NULL; i++); if (i) { - char *strlist[i + 1]; + char **strlist = ch_malloc ((i + 1) * sizeof(char *)); + if (strlist == NULL) { + if (out == NULL) + ch_free (ret); + return NULL; + } for (i = 0; bvlist[i] != NULL; i++) { strlist[i] = bvlist[i]->bv_val; } strlist[i] = NULL; ret->bv_val = Tcl_Merge(i, strlist); ret->bv_len = ret->bv_val ? strlen(ret->bv_val) : 0; + ch_free (strlist); } return ret;