From: Howard Chu Date: Sat, 13 Sep 2003 10:20:27 +0000 (+0000) Subject: ITS#2691 use putenv() instead of setenv() for portability X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~728 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ffab52e529269b07af4cd0b489805e480385a443;p=openldap ITS#2691 use putenv() instead of setenv() for portability --- diff --git a/contrib/ldapsasl/ldapdb.c b/contrib/ldapsasl/ldapdb.c index 45a08ac426..b2c408e3bc 100644 --- a/contrib/ldapsasl/ldapdb.c +++ b/contrib/ldapsasl/ldapdb.c @@ -222,8 +222,19 @@ static int ldapdb_auxprop_plug_init(const sasl_utils_t *utils, utils->getopt(utils->getopt_context, ldapdb, "ldapdb_mech", (const char **)&tmp.mech.bv_val, &len); tmp.mech.bv_len = len; - utils->getopt(utils->getopt_context, ldapdb, "ldapdb_rc", &s, NULL); - if(s && setenv("LDAPRC", s, 1)) return SASL_BADPARAM; + utils->getopt(utils->getopt_context, ldapdb, "ldapdb_rc", &s, &len); + if (s) + { + char *str = utils->malloc(sizeof("LDAPRC=")+len); + if (!str) return SASL_NOMEM; + strcpy( str, "LDAPRC=" ); + strcpy( str + sizeof("LDAPRC=")-1, s ); + if (putenv(str)) + { + utils->free(str); + return SASL_NOMEM; + } + } p = utils->malloc(sizeof(ldapctx)); if (!p) return SASL_NOMEM;