You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by sterling <st...@covalent.net> on 2001/08/22 21:56:41 UTC
[PATCH] mod_mime.c core dumps with no AddType
It appears that the extension_mappings hash is initialized to null, then
only instanciated if there is an AddType call in your conf file. Hence in
the type_checker phase it tries to perform a lookup on a null hash.
this patch should fix the crash, but IMHO by that point the
extension_mappings hash should just be empty, not null (i.e. it should be
initialized to apr_hash_make) --
sterling
Index: modules/http/mod_mime.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/mod_mime.c,v
retrieving revision 1.55
diff -u -r1.55 mod_mime.c
--- modules/http/mod_mime.c 2001/08/19 05:48:18 1.55
+++ modules/http/mod_mime.c 2001/08/22 19:45:04
@@ -812,7 +812,7 @@
/* Parse filename extensions which can be in any order
*/
while (*fn && (ext = ap_getword(r->pool, &fn, '.'))) {
- extension_info *exinfo;
+ extension_info *exinfo = NULL;
int found;
if (*ext == '\0') /* ignore empty extensions "bad..html" */
@@ -827,9 +827,10 @@
ap_str_tolower(ext);
#endif
- exinfo = (extension_info*) apr_hash_get(conf->extension_mappings,
- ext, APR_HASH_KEY_STRING);
-
+ if( conf->extension_mappings != NULL ) {
+ exinfo = (extension_info*) apr_hash_get(conf->extension_mappings,
+ ext, APR_HASH_KEY_STRING);
+ }
if (exinfo == NULL) {
if ((type = apr_hash_get(mime_type_extensions, ext,
APR_HASH_KEY_STRING)) != NULL) {
Re: [PATCH] mod_mime.c core dumps with no AddType
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
From: "Jeff Trawick" <tr...@attglobal.net>
Sent: Wednesday, August 22, 2001 3:19 PM
> sterling <st...@covalent.net> writes:
>
> > this patch should fix the crash, but IMHO by that point the
> > extension_mappings hash should just be empty, not null (i.e. it should be
> > initialized to apr_hash_make) --
>
> +1 to a patch which initializes apr_hash_make() more sanely so we
> don't have to keep checking
-1 until we revert to tables.
Re: [PATCH] mod_mime.c core dumps with no AddType
Posted by sterling <st...@covalent.net>.
Hey jeff -
On 22 Aug 2001, Jeff Trawick wrote:
> sterling <st...@covalent.net> writes:
>
> > It appears that the extension_mappings hash is initialized to null, then
> > only instanciated if there is an AddType call in your conf file. Hence in
> > the type_checker phase it tries to perform a lookup on a null hash.
> >
> > this patch should fix the crash, but IMHO by that point the
> > extension_mappings hash should just be empty, not null (i.e. it should be
> > initialized to apr_hash_make) --
>
> +1 to a patch which initializes apr_hash_make() more sanely so we
> don't have to keep checking
>
>
that would be my pleasure -
sterling.
Index: modules/http/mod_mime.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/mod_mime.c,v
retrieving revision 1.56
diff -u -r1.56 mod_mime.c
--- modules/http/mod_mime.c 2001/08/22 20:03:47 1.56
+++ modules/http/mod_mime.c 2001/08/22 20:20:39
@@ -149,7 +149,7 @@
mime_dir_config *new =
(mime_dir_config *) apr_palloc(p, sizeof(mime_dir_config));
- new->extension_mappings = NULL;
+ new->extension_mappings = apr_hash_make(p);
new->charsets_remove = NULL;
new->encodings_remove = NULL;
@@ -827,10 +827,8 @@
ap_str_tolower(ext);
#endif
- if (conf->extension_mappings != NULL) {
- exinfo = (extension_info*)apr_hash_get(conf->extension_mappings,
- ext, APR_HASH_KEY_STRING);
- }
+ exinfo = (extension_info*)apr_hash_get(conf->extension_mappings,
+ ext, APR_HASH_KEY_STRING);
if (exinfo == NULL) {
if ((type = apr_hash_get(mime_type_extensions, ext,
Re: [PATCH] mod_mime.c core dumps with no AddType
Posted by Jeff Trawick <tr...@attglobal.net>.
sterling <st...@covalent.net> writes:
> It appears that the extension_mappings hash is initialized to null, then
> only instanciated if there is an AddType call in your conf file. Hence in
> the type_checker phase it tries to perform a lookup on a null hash.
>
> this patch should fix the crash, but IMHO by that point the
> extension_mappings hash should just be empty, not null (i.e. it should be
> initialized to apr_hash_make) --
+1 to a patch which initializes apr_hash_make() more sanely so we
don't have to keep checking
--
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...
Re: [PATCH] mod_mime.c core dumps with no AddType
Posted by Brian Pane <bp...@pacbell.net>.
William A. Rowe, Jr. wrote:
>From: "sterling" <st...@covalent.net>
>
>
>>It appears that the extension_mappings hash is initialized to null, then
>>only instanciated if there is an AddType call in your conf file. Hence in
>>the type_checker phase it tries to perform a lookup on a null hash.
>>
>>this patch should fix the crash, but IMHO by that point the
>>extension_mappings hash should just be empty, not null (i.e. it should be
>>initialized to apr_hash_make) --
>>
>
>No ... it should not.
>
>Even an empty hash must be merged in merge_per_dir_configs ... and that's
>very time consuming.
>
There's no need to merge an empty hash. If you're optimizing away the
merge in the case where the pointer to the hash table is NULL, the same
optimization is applicable in the case where the hash table exists but
is empty (apr_hash_count() takes O(1) time).
--Brian
Re: [PATCH] mod_mime.c core dumps with no AddType
Posted by sterling <st...@covalent.net>.
Welp -
the first patch i submitted made the least changes possible and fixes the
core dump - so you can revert to that
sterling
On Wed, 22 Aug 2001, William A. Rowe, Jr. wrote:
> From: "sterling" <st...@covalent.net>
>
>
> > It appears that the extension_mappings hash is initialized to null, then
> > only instanciated if there is an AddType call in your conf file. Hence in
> > the type_checker phase it tries to perform a lookup on a null hash.
> >
> > this patch should fix the crash, but IMHO by that point the
> > extension_mappings hash should just be empty, not null (i.e. it should be
> > initialized to apr_hash_make) --
>
> No ... it should not.
>
> Even an empty hash must be merged in merge_per_dir_configs ... and that's
> very time consuming.
>
> Bill
>
>
>
Re: [PATCH] mod_mime.c core dumps with no AddType
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
From: "sterling" <st...@covalent.net>
> It appears that the extension_mappings hash is initialized to null, then
> only instanciated if there is an AddType call in your conf file. Hence in
> the type_checker phase it tries to perform a lookup on a null hash.
>
> this patch should fix the crash, but IMHO by that point the
> extension_mappings hash should just be empty, not null (i.e. it should be
> initialized to apr_hash_make) --
No ... it should not.
Even an empty hash must be merged in merge_per_dir_configs ... and that's
very time consuming.
Bill