Index: include/http_protocol.h =================================================================== --- include/http_protocol.h (revision 1828935) +++ include/http_protocol.h (working copy) @@ -631,7 +631,9 @@ AP_DECLARE(apr_status_t) ap_get_basic_auth_compone AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri); #define AP_GETLINE_FOLD 1 /* Whether to merge continuation lines */ -#define AP_GETLINE_CRLF 2 /*Whether line ends must be in the form CR LF */ +#define AP_GETLINE_CRLF 2 /* Whether line ends must be in the form CR LF */ +#define AP_GETLINE_NOSPC_EOL 4 /* Whether to consume up to and including the + end of line on APR_ENOSPC */ /** * Get the next line of input for the request Index: server/protocol.c =================================================================== --- server/protocol.c (revision 1828935) +++ server/protocol.c (working copy) @@ -224,6 +224,8 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s int do_alloc = (*s == NULL), saw_eos = 0; int fold = flags & AP_GETLINE_FOLD; int crlf = flags & AP_GETLINE_CRLF; + int nospc_eol = flags & AP_GETLINE_NOSPC_EOL; + int eol = 0; if (!n) { /* Needs room for NUL byte at least */ @@ -239,7 +241,7 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s if (last_char) *last_char = '\0'; - for (;;) { + do { apr_brigade_cleanup(bb); rv = ap_get_brigade(r->proto_input_filters, bb, AP_MODE_GETLINE, APR_BLOCK_READ, 0); @@ -283,8 +285,19 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s /* Would this overrun our buffer? If so, we'll die. */ if (n < bytes_handled + len) { + /* But before we'll fill in the buffer up to its limit (i.e. + * fall through with the remaining length if necessary), and + * optionally (nospc_eol) consume the end of line until LF. + */ rv = APR_ENOSPC; - goto cleanup; + eol = (str[len - 1] == APR_ASCII_LF); + len = n - bytes_handled; + if (!len) { + if (nospc_eol) { + continue; + } + goto cleanup; + } } /* Do we have to handle the allocation ourselves? */ @@ -323,8 +336,13 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s /* If we got a full line of input, stop reading */ if (last_char && (*last_char == APR_ASCII_LF)) { - break; + eol = 1; } + } while (!eol); + + if (rv != APR_SUCCESS) { + /* End of line after APR_ENOSPC above */ + goto cleanup; } /* Now terminate the string at the end of the line;