httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Fritsch ...@sfritsch.de>
Subject Re: Fwd: svn commit: r1197405 - in /httpd/httpd/trunk: CHANGES docs/manual/upgrading.xml modules/filters/mod_substitute.c
Date Sun, 06 Nov 2011 18:44:26 GMT
On Sun, 6 Nov 2011, Ruediger Pluem wrote:
>>> @@ -188,25 +197,36 @@ static void do_pattmatch(ap_filter_t *f,
>>>                     int left = bytes;
>>>                     const char *pos = buff;
>>>                     char *repl;
>>> +                    apr_size_t space_left = AP_SUBST_MAX_LINE_LENGTH;
>>>                     while (!ap_regexec_len(script->regexp, pos, left,
>>>                                        AP_MAX_REG_MATCH, regm, 0)) {
>>> +                        apr_status_t rv;
>>>                         have_match = 1;
>>>                         if (script->flatten&&  !force_quick) {
>>>                             /* copy bytes before the match */
>>>                             if (regm[0].rm_so>  0)
>>>                                 ap_varbuf_strmemcat(&vb, pos,
>>> regm[0].rm_so);
>>>                             /* add replacement string */
>>> -                            ap_varbuf_regsub(&vb,
>>> script->replacement, pos,
>>> -                                             AP_MAX_REG_MATCH, regm, 0);
>>> +                            rv = ap_varbuf_regsub(&vb,
>>> script->replacement, pos,
>>> +                                                  AP_MAX_REG_MATCH,
>>> regm,
>>> +
>>> AP_SUBST_MAX_LINE_LENGTH - vb.strlen);
>>> +                            if (rv != APR_SUCCESS)
>>> +                                return rv;
>>>                         }
>>>                         else {
>>> -                            ap_pregsub_ex(pool,&repl,
>>> script->replacement, pos,
>>> -                                              AP_MAX_REG_MATCH, regm,
>>> 0);
>>> +                            apr_size_t repl_len;
>>> +                            rv = ap_pregsub_ex(pool,&repl,
>>> +                                               script->replacement, pos,
>>> +                                               AP_MAX_REG_MATCH, regm,
>>> +                                               space_left);
>>> +                            if (rv != APR_SUCCESS)
>>> +                                return rv;
>>>                             len = (apr_size_t) (regm[0].rm_eo -
>>> regm[0].rm_so);
>>> +                            repl_len = strlen(repl);
>>> +                            space_left -= len + repl_len;
>>>
>>>
>>> Isn't it sufficient to reduce space_left only by repl_len?
>>> IMHO we only allocate repl_len new memory in ap_pregsub_ex and not len
>>> + repl_len or am I wrong here?
>>>
>>>
>
>
> Any comment on that?

That was also supposed to cause the line length to be limited instead of 
the length of the replacement. But you are right, this is not correct. I 
will look at it during the hackathon.

Mime
View raw message