source: trunk/server/common/patches/httpd-2.2.x-CVE-2012-0053.patch @ 2139

Last change on this file since 2139 was 2134, checked in by achernya, 12 years ago
Patch httpd against some security vulnerabilities.
File size: 4.3 KB
  • httpd/httpd/branches/2.2.x/server/protocol.c

     
    670670    return 1;
    671671}
    672672
     673/* get the length of the field name for logging, but no more than 80 bytes */
     674#define LOG_NAME_MAX_LEN 80
     675static int field_name_len(const char *field)
     676{
     677    const char *end = ap_strchr_c(field, ':');
     678    if (end == NULL || end - field > LOG_NAME_MAX_LEN)
     679        return LOG_NAME_MAX_LEN;
     680    return end - field;
     681}
     682
    673683AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb)
    674684{
    675685    char *last_field = NULL;
     
    709719                /* insure ap_escape_html will terminate correctly */
    710720                field[len - 1] = '\0';
    711721                apr_table_setn(r->notes, "error-notes",
    712                                apr_pstrcat(r->pool,
     722                               apr_psprintf(r->pool,
    713723                                           "Size of a request header field "
    714724                                           "exceeds server limit.<br />\n"
    715                                            "<pre>\n",
    716                                            ap_escape_html(r->pool, field),
    717                                            "</pre>\n", NULL));
     725                                           "<pre>\n%.*s\n</pre>/n",
     726                                           field_name_len(field),
     727                                           ap_escape_html(r->pool, field)));
     728                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
     729                              "Request header exceeds LimitRequestFieldSize: "
     730                              "%.*s", field_name_len(field), field);
    718731            }
    719732            return;
    720733        }
     
    735748                     * overflow (last_field) as the field with the problem
    736749                     */
    737750                    apr_table_setn(r->notes, "error-notes",
    738                                    apr_pstrcat(r->pool,
     751                                   apr_psprintf(r->pool,
    739752                                               "Size of a request header field "
    740753                                               "after folding "
    741754                                               "exceeds server limit.<br />\n"
    742                                                "<pre>\n",
    743                                                ap_escape_html(r->pool, last_field),
    744                                                "</pre>\n", NULL));
     755                                               "<pre>\n%.*s\n</pre>\n",
     756                                               field_name_len(last_field),
     757                                               ap_escape_html(r->pool, last_field)));
     758                    ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
     759                                  "Request header exceeds LimitRequestFieldSize "
     760                                  "after folding: %.*s",
     761                                  field_name_len(last_field), last_field);
    745762                    return;
    746763                }
    747764
     
    773790                if (!(value = strchr(last_field, ':'))) { /* Find ':' or    */
    774791                    r->status = HTTP_BAD_REQUEST;      /* abort bad request */
    775792                    apr_table_setn(r->notes, "error-notes",
    776                                    apr_pstrcat(r->pool,
     793                                   apr_psprintf(r->pool,
    777794                                               "Request header field is "
    778795                                               "missing ':' separator.<br />\n"
    779                                                "<pre>\n",
     796                                               "<pre>\n%.*s</pre>\n",
     797                                               (int)LOG_NAME_MAX_LEN,
    780798                                               ap_escape_html(r->pool,
    781                                                               last_field),
    782                                                "</pre>\n", NULL));
     799                                                              last_field)));
     800                    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
     801                                  "Request header field is missing ':' "
     802                                  "separator: %.*s", (int)LOG_NAME_MAX_LEN,
     803                                  last_field);
     804
    783805                    return;
    784806                }
    785807
Note: See TracBrowser for help on using the repository browser.