summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Kew <niq@apache.org>2006-08-18 12:16:13 +0000
committerNick Kew <niq@apache.org>2006-08-18 12:16:13 +0000
commit07e5187677255b67329c84bccff579c8858cbf0b (patch)
tree043cd261f047472b69d84661b30a59bbf03b738b
parenta187478d9ed1c0b4b9fbadb24c6c6c937538a838 (diff)
downloadhttpd-07e5187677255b67329c84bccff579c8858cbf0b.tar.gz
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
-rw-r--r--modules/database/mod_dbd.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/modules/database/mod_dbd.c b/modules/database/mod_dbd.c
index c236fedd86..76eeca2b4c 100644
--- a/modules/database/mod_dbd.c
+++ b/modules/database/mod_dbd.c
@@ -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;