mod_proxy_fcgi: Fix a potential crash with response headers' size above 8K.
[Teguh <chain rop.io>, Yann Ylavic]
+ *) mod_authnz_fcgi: Fix a potential crash with response headers' size above 8K.
+ [Yann Ylavic]
+
*) mod_authnz_ldap: Resolve crashes with LDAP authz and non-LDAP authn since
r1608202. [Eric Covener]
*
* Returns 0 if it can't find the end of the headers, and 1 if it found the
* end of the headers. */
-static int handle_headers(request_rec *r,
- int *state,
- char *readbuf)
+static int handle_headers(request_rec *r, int *state,
+ char *readbuf, apr_size_t readlen)
{
const char *itr = readbuf;
- while (*itr) {
+ while (readlen) {
if (*itr == '\r') {
switch (*state) {
case HDR_STATE_GOT_CRLF:
break;
}
}
- else {
+ else if (*itr == '\t' || !apr_iscntrl(*itr)) {
*state = HDR_STATE_READING_HEADERS;
}
+ else {
+ return -1;
+ }
if (*state == HDR_STATE_DONE_WITH_HEADERS)
break;
+ --readlen;
++itr;
}
APR_BRIGADE_INSERT_TAIL(ob, b);
if (!seen_end_of_headers) {
- int st = handle_headers(r, &header_state, readbuf);
+ int st = handle_headers(r, &header_state, readbuf,
+ readbuflen);
+
+ if (st == -1) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+ APLOGNO(02821) "%s: error reading "
+ "headers from %s",
+ fn, conf->backend);
+ rv = APR_EINVAL;
+ break;
+ }
if (st == 1) {
int status;
/*
* Read/discard any trailing padding.
*/
- if (plen) {
+ if (rv == APR_SUCCESS && plen) {
rv = recv_data_full(conf, r, s, readbuf, plen);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,