httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvaug...@aventail.com
Subject problem in http_config.c:ap_handle_command?
Date Mon, 17 May 1999 19:14:43 GMT
In http_config.c:ap_handle_command

[ 1]	else {
[ 2]	    void *mconfig = ap_get_module_config(config, mod);
[ 3]	    void *sconfig =
[ 4]		ap_get_module_config(parms->server->module_config, mod);
[ 5]
[ 6]	    if (!mconfig && mod->create_dir_config) {
[ 7]		mconfig = (*mod->create_dir_config) (parms->pool, parms->path);
[ 8]		ap_set_module_config(config, mod, mconfig);
[ 9]	    }
[10]
[11]	    if (!sconfig && mod->create_server_config) {
[12]		sconfig =
[13]		    (*mod->create_server_config) (parms->pool, parms->server);
[14]		ap_set_module_config(parms->server->module_config, mod, sconfig);
[15]	    }
[16]
[17]	    retval = invoke_cmd(cmd, parms, mconfig, args);
[18]	    mod = mod->next;	/* Next time around, skip this one */
[19]	}

It seems pretty legit that at #2 mconfig could come up NULL. Why, I
dunno. But at any rate, mconfig is created, possibly, at #7. mconfig will
*not* be created if the module in question does not have a per-directory
configuration create hook, see #6.

The problem lies at #17. mconfig is passed to invoke_cmd. But there is the
possiblity that mconfig could be NULL at this point. This module causes a
SIGSEGV because of this.

#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_main.h"
#include "http_protocol.h"

module MODULE_VAR_EXPORT ass_module;

typedef struct _ass_sconfig_t {
	char *ass_uri;
	char *tmpl_dir;
} ass_sconfig_t;

static void *
server_config_create(pool *p, server_rec *s)
{
    ass_sconfig_t *sconfig;

    sconfig = (ass_sconfig_t *) ap_pcalloc(p, sizeof(ass_sconfig_t));

    sconfig->ass_uri   = "/ass";
    sconfig->tmpl_dir  = ap_server_root_relative(p, "templates/");

    return (void *) sconfig;
}

static const command_rec
ass_commands[] = {
    { "AssURI", ap_set_string_slot,
	  (void *) XtOffsetOf(ass_sconfig_t, ass_uri), RSRC_CONF, TAKE1,
	  "this explains this directive" },
    { "AssTmplDir", ap_set_file_slot,
	  (void *) XtOffsetOf(ass_sconfig_t, tmpl_dir), RSRC_CONF, TAKE1,
	  "this explains this directive" },
    { NULL }
};

module MODULE_VAR_EXPORT ass_module = {
   STANDARD_MODULE_STUFF,
   NULL,                        /* module initializer                  */
   NULL,                        /* create per-dir    config structures */
   NULL,                        /* merge  per-dir    config structures */
   server_config_create,        /* create per-server config structures */
   NULL,                        /* merge  per-server config structures */
   ass_commands,                /* table of config file commands       */
   NULL,                        /* [#8] MIME-typed-dispatched handlers */
   NULL,                        /* [#1] URI to filename translation    */
   NULL,                        /* [#4] validate user id from request  */
   NULL,                        /* [#5] check if the user is ok _here_ */
   NULL,                        /* [#3] check access by host address   */
   NULL,                        /* [#6] determine MIME type            */
   NULL,                        /* [#7] pre-run fixups                 */
   NULL,                        /* [#9] log a transaction              */
   NULL,                        /* [#2] header parser                  */
   NULL,                        /* child_init                          */
   NULL,                        /* child_exit                          */
   NULL                         /* [#0] post read-request              */
};

Here is a backtrace:

(gdb) bt
#0  0x8066604 in ap_set_file_slot (cmd=0xbffffb08, struct_ptr=0x0, arg=0x80a18dc "templates/")
at http_config.c:1068
#1  0x8065b44 in invoke_cmd (cmd=0x808f8cc, parms=0xbffffb08, mconfig=0x0, args=0xbfffdaad
"") at http_config.c:805
#2  0x8066477 in ap_handle_command (parms=0xbffffb08, config=0x80a10f4, l=0xbfffda98 "AssTmplDir
templates/") at http_config.c:1000
#3  0x8066508 in ap_srm_command_loop (parms=0xbffffb08, config=0x80a10f4) at http_config.c:1013
#4  0x8066904 in ap_process_resource_config (s=0x80a059c, fname=0x80a17fc "/users/tvaughan/apache/conf/httpd.conf",
p=0x80a0574, ptemp=0x80a2584) at http_config.c:1193
#5  0x80671c2 in ap_read_config (p=0x80a0574, ptemp=0x80a2584, confname=0x809e550 "conf/httpd.conf")
at http_config.c:1472
#6  0x8070eae in main (argc=2, argv=0xbffffbc0) at http_main.c:4574

This module is not a DSO. And either:

        AssURI /foobar
        AssTmplDir foobar/

in any order, anywhere (not that I've tried every combination) will cause
this to happen.

So, am I overlooking something obvious? Done something stupid? Or is this a
problem? Why would sconfig not be passed to invoke_cmd?

Apache: 1.3.6
OS: RH 5.2 GNU/Linux
Compiler: egcs

Much Thanks,
Tom

-- 
Tom Vaughan <tvaughan at aventail dot com>

Mime
View raw message