mirror of
https://github.com/apache/httpd.git
synced 2025-08-13 14:40:20 +00:00
Don't use NULL s->server_hostname as hash lookup key.
Reported by paritosh (at limewire.co.in) on dev@httpd (thread Re: apache 2.2 crashes at the start time in mod_dbd.c then preparing AuthDBDUserPWQuery) Fixed by paritosh and Yours Truly. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@432560 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@ -68,6 +68,7 @@ typedef enum { cmd_name, cmd_params, cmd_persist,
|
||||
} cmd_parts;
|
||||
|
||||
static apr_hash_t *dbd_prepared_defns;
|
||||
static const char *const default_hostname = "*";
|
||||
|
||||
/* a default DBDriver value that'll generate meaningful error messages */
|
||||
static const char *const no_dbdriver = "[DBDriver unset]";
|
||||
@ -147,12 +148,14 @@ DBD_DECLARE_NONSTD(void) ap_dbd_prepare(server_rec *s, const char *query,
|
||||
const char *label)
|
||||
{
|
||||
dbd_prepared *prepared = apr_pcalloc(s->process->pool, sizeof(dbd_prepared));
|
||||
const char *key = s->server_hostname;
|
||||
if (key == NULL) {
|
||||
key = default_hostname;
|
||||
}
|
||||
prepared->label = label;
|
||||
prepared->query = query;
|
||||
prepared->next = apr_hash_get(dbd_prepared_defns, s->server_hostname,
|
||||
APR_HASH_KEY_STRING);
|
||||
apr_hash_set(dbd_prepared_defns, s->server_hostname, APR_HASH_KEY_STRING,
|
||||
prepared);
|
||||
prepared->next = apr_hash_get(dbd_prepared_defns, key, APR_HASH_KEY_STRING);
|
||||
apr_hash_set(dbd_prepared_defns, key, APR_HASH_KEY_STRING, prepared);
|
||||
}
|
||||
static const char *dbd_prepare(cmd_parms *cmd, void *cfg, const char *query,
|
||||
const char *label)
|
||||
@ -618,8 +621,12 @@ static int dbd_post_config(apr_pool_t *pconf, apr_pool_t *plog,
|
||||
svr_cfg *svr;
|
||||
server_rec *sp;
|
||||
for (sp = s; sp; sp = sp->next) {
|
||||
const char *key = s->server_hostname;
|
||||
if (key == NULL) {
|
||||
key = default_hostname;
|
||||
}
|
||||
svr = ap_get_module_config(sp->module_config, &dbd_module);
|
||||
svr->prepared = apr_hash_get(dbd_prepared_defns, sp->server_hostname,
|
||||
svr->prepared = apr_hash_get(dbd_prepared_defns, key,
|
||||
APR_HASH_KEY_STRING);
|
||||
}
|
||||
return OK;
|
||||
|
Reference in New Issue
Block a user