

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
5 messages in org.apache.httpd.devregex-related segfault in mod_include| From | Sent On | Attachments |
|---|---|---|
| Lars Eilebrecht | Feb 26, 2009 10:58 am | |
| Ruediger Pluem | Feb 26, 2009 11:38 am | |
| Lars Eilebrecht | Feb 27, 2009 3:53 am | |
| "Plüm, Rüdiger, VF-Group" | Feb 27, 2009 6:29 am | |
| Lars Eilebrecht | Feb 27, 2009 7:22 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | regex-related segfault in mod_include | Actions... |
|---|---|---|
| From: | Lars Eilebrecht (la...@eilebrecht.net) | |
| Date: | Feb 26, 2009 10:58:33 am | |
| List: | org.apache.httpd.dev | |
Hi,
the following SSI statements triggers a segfault when QUERY_STRING is empty (tested with 2.2.11):
<!--#if expr="$QUERY_STRING = /foobar=([0-9]+)$/" --> <!--#set var="foobar" value="$1" --> <!--#else --> <!--#set var="foobar" value="$1" --> <!--#endif -->
I tracked this down to get_include_var() in mod_include.c:
--snip-- static const char *get_include_var(const char *var, include_ctx_t *ctx) { const char *val; request_rec *r = ctx->intern->r;
if (apr_isdigit(*var) && !var[1]) { apr_size_t idx = *var - '0'; backref_t *re = ctx->intern->re;
/* Handle $0 .. $9 from the last regex evaluated. * The choice of returning NULL strings on not-found, * v.s. empty strings on an empty match is deliberate. */ if (!re) { ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "regex capture $%" APR_SIZE_T_FMT " refers to no regex in %s", idx, r->filename); return NULL; } else { if (re->nsub < idx || idx >= AP_MAX_REG_MATCH) { ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "regex capture $%" APR_SIZE_T_FMT " is out of range (last regex was: '%s') in %s", idx, re->rexp, r->filename); return NULL; }
if (re->match[idx].rm_so < 0 || re->match[idx].rm_eo < 0) { return NULL; }
val = apr_pstrmemdup(ctx->dpool, re->source + re->match[idx].rm_so, re->match[idx].rm_eo - re->match[idx].rm_so); } } else { val = apr_table_get(r->subprocess_env, var);
if (val == LAZY_VALUE) { val = add_include_vars_lazy(r, var); } }
return val; } --snip--
The segfault happens with apr_pstrmemdup(), because "re->source + re->match[idx].rm_so" ends up being out of bounds.
So despite the regex not matching, "ctx->intern->re" is actually not NULL, but I can't seem to figure out why this is the case.
Anyone any idea?
ciao...
-- Lars Eilebrecht la...@eilebrecht.net







