[mod_python] [PATCH] fix filter lookup failure

Gary Benson gbenson at redhat.com
Thu Sep 12 11:25:30 EST 2002


Hi,

ap_register_*_filter() normalizes the filter's name before it stores it
by converting it to lower case and removing special characters.  If the
name is not the same when normalized then python_filter() will not be
able to work out which filter it is and will segfault.  The attached
patch fixes.

Later,
Gary

[ gbenson at redhat.com ][ GnuPG 85A8F78B ][ http://inauspicious.org/ ]
-------------- next part --------------
ap_register_*_filter normalizes the filter's name, so we need to store
the normalized name for filter lookups rather than the name the user
registered it with.

Index: src/mod_python.c
===================================================================
RCS file: /cvsroot/modpython/mod_python/src/mod_python.c,v
retrieving revision 1.73
diff -u -r1.73 mod_python.c
--- src/mod_python.c	6 Sep 2002 22:06:28 -0000	1.73
+++ src/mod_python.c	11 Sep 2002 15:58:56 -0000
@@ -1479,23 +1479,24 @@
 
     py_config *conf;
     py_handler *fh;
+    ap_filter_rec_t *frec;
     
     if (!name)
         name = apr_pstrdup(cmd->pool, handler);
 
+    /* register the filter NOTE - this only works so long as the
+       directive is only allowed in the main config. For .htaccess we
+       would have to make sure not to duplicate this */
+    frec = ap_register_input_filter(name, python_input_filter, NULL, AP_FTYPE_CONNECTION);
+ 
     conf = (py_config *) mconfig;
 
     fh = (py_handler *) apr_pcalloc(cmd->pool, sizeof(py_handler));
     fh->handler = (char *)handler;
     fh->dir = conf->config_dir;
 
-    apr_hash_set(conf->in_filters, name, APR_HASH_KEY_STRING, fh);
+    apr_hash_set(conf->in_filters, frec->name, APR_HASH_KEY_STRING, fh);
 
-    /* register the filter NOTE - this only works so long as the
-       directive is only allowed in the main config. For .htaccess we
-       would have to make sure not to duplicate this */
-    ap_register_input_filter(name, python_input_filter, NULL, AP_FTYPE_CONNECTION);
- 
     return NULL;
 }
 
@@ -1503,23 +1504,24 @@
                                                 const char *handler, const char *name) {
     py_config *conf;
     py_handler *fh;
+    ap_filter_rec_t *frec;
  
     if (!name)
         name = apr_pstrdup(cmd->pool, handler);
 
+    /* register the filter NOTE - this only works so long as the
+       directive is only allowed in the main config. For .htaccess we
+       would have to make sure not to duplicate this */
+    frec = ap_register_output_filter(name, python_output_filter, NULL, AP_FTYPE_RESOURCE);
+ 
     conf = (py_config *) mconfig;
     
     fh = (py_handler *) apr_pcalloc(cmd->pool, sizeof(py_handler));
     fh->handler = (char *)handler;
     fh->dir = conf->config_dir;
 
-    apr_hash_set(conf->out_filters, name, APR_HASH_KEY_STRING, fh);
+    apr_hash_set(conf->out_filters, frec->name, APR_HASH_KEY_STRING, fh);
 
-    /* register the filter NOTE - this only works so long as the
-       directive is only allowed in the main config. For .htaccess we
-       would have to make sure not to duplicate this */
-    ap_register_output_filter(name, python_output_filter, NULL, AP_FTYPE_RESOURCE);
- 
     return NULL;
 }
 


More information about the Mod_python mailing list