stas 2003/01/16 19:08:31
Modified: src/modules/perl modperl_filter.c modperl_filter.h
. Changes
xs modperl_xs_util.h
xs/Apache/RequestIO Apache__RequestIO.h
xs/tables/current/ModPerl FunctionTable.pm
Log:
prevent segfault in $r->print / $filter->print (in output filter) and
related functions when they are called before the response phase
Revision Changes Path
1.44 +11 -4 modperl-2.0/src/modules/perl/modperl_filter.c
Index: modperl_filter.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- modperl_filter.c 15 Jan 2003 06:07:10 -0000 1.43
+++ modperl_filter.c 17 Jan 2003 03:08:31 -0000 1.44
@@ -55,13 +55,18 @@
return rv;
}
-MP_INLINE apr_status_t modperl_wbucket_write(modperl_wbucket_t *wb,
+MP_INLINE apr_status_t modperl_wbucket_write(pTHX_ modperl_wbucket_t *wb,
const char *buf,
apr_size_t *wlen)
{
apr_size_t len = *wlen;
*wlen = 0;
+ if (!wb) {
+ /* the response is not initialized yet */
+ Perl_croak(aTHX_ "can't be called before the response phase");
+ }
+
if ((len + wb->outcnt) > sizeof(wb->outbuf)) {
apr_status_t rv;
if ((rv = modperl_wbucket_flush(wb)) != APR_SUCCESS) {
@@ -505,7 +510,8 @@
return filter->rc;
}
-MP_INLINE apr_status_t modperl_input_filter_write(modperl_filter_t *filter,
+MP_INLINE apr_status_t modperl_input_filter_write(pTHX_
+ modperl_filter_t *filter,
const char *buf,
apr_size_t *len)
{
@@ -519,11 +525,12 @@
return APR_SUCCESS;
}
-MP_INLINE apr_status_t modperl_output_filter_write(modperl_filter_t *filter,
+MP_INLINE apr_status_t modperl_output_filter_write(pTHX_
+ modperl_filter_t *filter,
const char *buf,
apr_size_t *len)
{
- return modperl_wbucket_write(&filter->wbucket, buf, len);
+ return modperl_wbucket_write(aTHX_ &filter->wbucket, buf, len);
}
apr_status_t modperl_output_filter_handler(ap_filter_t *f,
1.17 +6 -3 modperl-2.0/src/modules/perl/modperl_filter.h
Index: modperl_filter.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- modperl_filter.h 15 Jan 2003 06:07:10 -0000 1.16
+++ modperl_filter.h 17 Jan 2003 03:08:31 -0000 1.17
@@ -16,7 +16,8 @@
MP_INLINE apr_status_t modperl_wbucket_flush(modperl_wbucket_t *b);
-MP_INLINE apr_status_t modperl_wbucket_write(modperl_wbucket_t *b,
+MP_INLINE apr_status_t modperl_wbucket_write(pTHX_
+ modperl_wbucket_t *b,
const char *buf,
apr_size_t *wlen);
@@ -50,7 +51,8 @@
SV *buffer,
apr_size_t wanted);
-MP_INLINE apr_status_t modperl_output_filter_write(modperl_filter_t *filter,
+MP_INLINE apr_status_t modperl_output_filter_write(pTHX_
+ modperl_filter_t *filter,
const char *buf,
apr_size_t *len);
@@ -75,7 +77,8 @@
SV *buffer,
apr_size_t wanted);
-MP_INLINE apr_status_t modperl_input_filter_write(modperl_filter_t *filter,
+MP_INLINE apr_status_t modperl_input_filter_write(pTHX_
+ modperl_filter_t *filter,
const char *buf,
apr_size_t *len);
1.103 +5 -2 modperl-2.0/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- Changes 17 Jan 2003 02:26:31 -0000 1.102
+++ Changes 17 Jan 2003 03:08:31 -0000 1.103
@@ -10,8 +10,11 @@
=item 1.99_09-dev
-fix segfault in send_http_header when it's called before the response
-phase [Stas]
+prevent segfault in $r->print/$filter->print and related functions
+when they are called before the response phase [Stas]
+
+prevent segfault in send_http_header when it's called before the
+response phase [Stas]
input stream filtering support was added + tests (plus renaming filter
tests so we can know from the test name what kind of filter is tested)
1.13 +1 -1 modperl-2.0/xs/modperl_xs_util.h
Index: modperl_xs_util.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/modperl_xs_util.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- modperl_xs_util.h 14 May 2002 03:12:56 -0000 1.12
+++ modperl_xs_util.h 17 Jan 2003 03:08:31 -0000 1.13
@@ -84,7 +84,7 @@
while (MARK <= SP) { \
apr_ssize_t wlen; \
char *buf = SvPV(*MARK, wlen); \
- apr_status_t rv = func(obj, buf, &wlen); \
+ apr_status_t rv = func(aTHX_ obj, buf, &wlen); \
if (rv != APR_SUCCESS) { \
Perl_croak(aTHX_ modperl_apr_strerror(rv)); \
} \
1.30 +2 -2 modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h
Index: Apache__RequestIO.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- Apache__RequestIO.h 17 Dec 2002 07:15:46 -0000 1.29
+++ Apache__RequestIO.h 17 Jan 2003 03:08:31 -0000 1.30
@@ -92,7 +92,7 @@
modperl_perl_do_sprintf(aTHX_ sv, items, MARK);
bytes = SvCUR(sv);
- modperl_wbucket_write(rcfg->wbucket, SvPVX(sv), &bytes);
+ modperl_wbucket_write(aTHX_ rcfg->wbucket, SvPVX(sv), &bytes);
mpxs_output_flush(r, rcfg);
@@ -124,7 +124,7 @@
wlen = bufsiz;
}
- modperl_wbucket_write(rcfg->wbucket, buf+offset, &wlen);
+ modperl_wbucket_write(aTHX_ rcfg->wbucket, buf+offset, &wlen);
return wlen;
}
1.96 +12 -0 modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm
Index: FunctionTable.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- FunctionTable.pm 17 Jan 2003 02:26:32 -0000 1.95
+++ FunctionTable.pm 17 Jan 2003 03:08:31 -0000 1.96
@@ -3253,6 +3253,10 @@
],
'args' => [
{
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
+ {
'type' => 'modperl_filter_t *',
'name' => 'filter'
},
@@ -3274,6 +3278,10 @@
],
'args' => [
{
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
+ {
'type' => 'modperl_filter_t *',
'name' => 'filter'
},
@@ -4467,6 +4475,10 @@
'__inline__'
],
'args' => [
+ {
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
{
'type' => 'modperl_wbucket_t *',
'name' => 'b'