Skip to content

Commit 289e1fb

Browse files
committed
apr_ldap: Make sure APR_EINIT returned when the DSO is already loaded
does not get returned as an error. Make sure DSO errors are passed accurately to the caller for all new API functions, leaving legacy API unchanged. git-svn-id: https://svn.apache.org/repos/asf/apr/apr-util/branches/1.7.x@1924470 13f79535-47bb-0310-9956-ffa450edef68
1 parent 78d23f1 commit 289e1fb

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

ldap/apr_ldap_stub.c

+20-12
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ static apr_status_t load_ldap(apr_pool_t *pool, const apr_ldap_driver_t **driver
7878
modname = "apr_ldap-" APR_STRINGIFY(APR_MAJOR_VERSION) ".so";
7979
#endif
8080
rv = apu_dso_load(NULL, &symbol, modname, "apr__ldap_fns", pool, err);
81-
if (rv == APR_SUCCESS) {
81+
if (rv == APR_SUCCESS || APR_EINIT == rv) {
8282
lfn = symbol;
83+
rv = APR_SUCCESS;
8384
}
8485

8586
if (driver) {
@@ -91,10 +92,17 @@ static apr_status_t load_ldap(apr_pool_t *pool, const apr_ldap_driver_t **driver
9192
return rv;
9293
}
9394

94-
#define LOAD_LDAP_STUB(pool, err, failres) \
95+
#define LOAD_LEGACY_STUB(pool, err, failres) \
9596
if (!lfn && (apr_ldap_get_driver(pool, NULL, err) != APR_SUCCESS)) \
9697
return failres;
9798

99+
#define LOAD_LDAP_STUB(pool, err) \
100+
{ \
101+
apr_status_t status; \
102+
if (!lfn && ((status = apr_ldap_get_driver(pool, NULL, err)) != APR_SUCCESS)) \
103+
return status; \
104+
}
105+
98106
#define CHECK_LDAP_STUB(failres) \
99107
if (!lfn) \
100108
return failres;
@@ -131,7 +139,7 @@ APU_DECLARE(apr_status_t) apr_ldap_get_driver(apr_pool_t *pool,
131139
APU_DECLARE_LDAP(int) apr_ldap_info(apr_pool_t *pool,
132140
apr_ldap_err_t **result_err)
133141
{
134-
LOAD_LDAP_STUB(pool, NULL, -1);
142+
LOAD_LEGACY_STUB(pool, NULL, -1);
135143
return lfn->info(pool, result_err);
136144
}
137145

@@ -142,7 +150,7 @@ APU_DECLARE_LDAP(int) apr_ldap_init(apr_pool_t *pool,
142150
int secure,
143151
apr_ldap_err_t **result_err)
144152
{
145-
LOAD_LDAP_STUB(pool, NULL, -1);
153+
LOAD_LEGACY_STUB(pool, NULL, -1);
146154
return lfn->init(pool, ldap, hostname, portno, secure, result_err);
147155
}
148156

@@ -151,7 +159,7 @@ APU_DECLARE_LDAP(int) apr_ldap_ssl_init(apr_pool_t *pool,
151159
int cert_file_type,
152160
apr_ldap_err_t **result_err)
153161
{
154-
LOAD_LDAP_STUB(pool, NULL, -1);
162+
LOAD_LEGACY_STUB(pool, NULL, -1);
155163
return lfn->ssl_init(pool, cert_auth_file, cert_file_type, result_err);
156164
}
157165

@@ -168,7 +176,7 @@ APU_DECLARE_LDAP(int) apr_ldap_get_option(apr_pool_t *pool,
168176
void *outvalue,
169177
apr_ldap_err_t **result_err)
170178
{
171-
LOAD_LDAP_STUB(pool, NULL, -1);
179+
LOAD_LEGACY_STUB(pool, NULL, -1);
172180
return lfn->get_option(pool, ldap, option, outvalue, result_err);
173181
}
174182

@@ -178,13 +186,13 @@ APU_DECLARE_LDAP(int) apr_ldap_set_option(apr_pool_t *pool,
178186
const void *invalue,
179187
apr_ldap_err_t **result_err)
180188
{
181-
LOAD_LDAP_STUB(pool, NULL, -1);
189+
LOAD_LEGACY_STUB(pool, NULL, -1);
182190
return lfn->set_option(pool, ldap, option, invalue, result_err);
183191
}
184192

185193
APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_init(apr_pool_t *pool)
186194
{
187-
LOAD_LDAP_STUB(pool, NULL, APR_EGENERAL);
195+
LOAD_LEGACY_STUB(pool, NULL, APR_EGENERAL);
188196
return lfn->rebind_init(pool);
189197
}
190198

@@ -193,7 +201,7 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_add(apr_pool_t *pool,
193201
const char *bindDN,
194202
const char *bindPW)
195203
{
196-
LOAD_LDAP_STUB(pool, NULL, APR_EGENERAL);
204+
LOAD_LEGACY_STUB(pool, NULL, APR_EGENERAL);
197205
return lfn->rebind_add(pool, ld, bindDN, bindPW);
198206
}
199207

@@ -210,7 +218,7 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_initialise(apr_pool_t *pool,
210218
apr_ldap_t **ldap,
211219
apu_err_t *err)
212220
{
213-
LOAD_LDAP_STUB(pool, err, APR_EINIT);
221+
LOAD_LDAP_STUB(pool, err);
214222
return lfn->initialise(pool, ldap, err);
215223
}
216224

@@ -220,7 +228,7 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_option_get(apr_pool_t *pool,
220228
apr_ldap_opt_t *outvalue,
221229
apu_err_t *err)
222230
{
223-
LOAD_LDAP_STUB(pool, err, APR_EINIT);
231+
LOAD_LDAP_STUB(pool, err);
224232
return lfn->option_get(pool, ldap, option, outvalue, err);
225233
}
226234

@@ -230,7 +238,7 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_option_set(apr_pool_t *pool,
230238
const apr_ldap_opt_t *invalue,
231239
apu_err_t *err)
232240
{
233-
LOAD_LDAP_STUB(pool, err, APR_EINIT);
241+
LOAD_LDAP_STUB(pool, err);
234242
return lfn->option_set(pool, ldap, option, invalue, err);
235243
}
236244

0 commit comments

Comments
 (0)