Changeset 3423
- Timestamp:
- 03/07/09 16:45:20 (8 months ago)
- Files:
-
- cherokee/trunk/cherokee/header.c (modified) (3 diffs)
- cherokee/trunk/cherokee/util.c (modified) (1 diff)
- cherokee/trunk/cherokee/util.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/cherokee/header.c
r3403 r3423 723 723 has_header_request (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cuint_t tail_len) 724 724 { 725 ret_t ret; 725 726 char *start; 726 727 char *end; … … 745 746 * to the beginning of the buffer. 746 747 */ 747 cherokee_buffer_move_to_begin (buffer, (int) crlf_len);748 cherokee_buffer_move_to_begin (buffer, (int) crlf_len); 748 749 } 749 750 … … 764 765 /* It could be a partial header, or maybe a POST request 765 766 */ 766 if (unlikely ((end = strstr(start, CRLF_CRLF)) == NULL)) { 767 if ((end = strstr (start, LF_LF)) == NULL) 768 return ret_not_found; 769 770 /* Found uncommon / non standard EOH, set header length 771 */ 772 hdr->input_header_len = ((int) (end - buffer->buf)) + CSZLEN(LF_LF); 773 return ret_ok; 774 } 775 776 /* Found standard EOH, set header length 777 */ 778 hdr->input_header_len = ((int) (end - buffer->buf)) + CSZLEN(CRLF_CRLF); 779 767 ret = cherokee_find_header_end_cstr (start, 768 (buffer->buf + buffer->len) - start, 769 &end, &crlf_len); 770 if (ret != ret_ok) { 771 return ret_not_found; 772 } 773 774 hdr->input_header_len = ((int) (end - buffer->buf)) + crlf_len; 775 780 776 return ret_ok; 781 777 } cherokee/trunk/cherokee/util.c
r3403 r3423 1583 1583 1584 1584 ret_t 1585 cherokee_find_header_end (cherokee_buffer_t *buf, 1586 char **end, 1587 cuint_t *sep_len) 1585 cherokee_find_header_end_cstr (char *c_str, 1586 cint_t c_len, 1587 char **end, 1588 cuint_t *sep_len) 1588 1589 { 1589 1590 char *p; 1590 1591 char *fin; 1591 1592 char *begin; 1592 char *limit; 1593 int len; 1594 1595 if (cherokee_buffer_is_empty (buf)) 1593 int cr_n, lf_n; 1594 1595 if ((c_str == NULL) || (c_len <= 0)) 1596 1596 return ret_not_found; 1597 1597 1598 p = buf->buf; 1599 fin = buf->buf + buf->len; 1600 limit = buf->buf + MAX_HEADER_LEN; 1598 p = c_str; 1599 fin = c_str + MIN(c_len, MAX_HEADER_LEN); 1601 1600 1602 1601 while (p < fin) { 1603 if (unlikely (p > limit)) { 1604 return ret_error; 1605 } 1606 1607 if ((*p == CHR_CR) || (*p == CHR_LF)) { 1608 len = 0; 1602 if ((*p == CHR_CR) || (*p == CHR_LF)) { 1603 cr_n = 0; 1604 lf_n = 0; 1609 1605 begin = p; 1610 while ((*p == CHR_CR) || (*p == CHR_LF)) { 1606 1607 /* Valid scenarios: 1608 * CR_n: [CRLF_CRLF] 0, 1, 1, 2, 2 | [LF_LF] 0, 0 1609 * LF_n: 0, 0, 1, 1, 2 | 1, 2 1610 * 1611 * so, the two forbidden situations are: 1612 * CR_n: 1, 2 1613 * LF_n: 2, 0 1614 */ 1615 while (p < fin) { 1611 1616 if (*p == CHR_LF) { 1612 l en += 1;1613 if (l en == 2) {1617 lf_n++; 1618 if (lf_n == 2) { 1614 1619 *end = begin; 1615 1620 *sep_len = (p - begin) + 1; 1616 1621 return ret_ok; 1617 1622 } 1623 1618 1624 } else if (*p == CHR_CR) { 1619 ; 1625 cr_n++; 1626 1620 1627 } else { 1621 1628 break; 1622 1629 } 1623 p += 1; 1630 1631 if (unlikely (((cr_n == 1) && (lf_n == 2)) || 1632 ((cr_n == 2) && (lf_n == 0)))) 1633 { 1634 return ret_error; 1635 } 1636 1637 p++; 1624 1638 } 1625 1639 } 1626 p += 1; 1640 1641 p++; 1627 1642 } 1628 1643 1629 1644 return ret_not_found; 1645 } 1646 1647 1648 ret_t 1649 cherokee_find_header_end (cherokee_buffer_t *buf, 1650 char **end, 1651 cuint_t *sep_len) 1652 { 1653 return cherokee_find_header_end_cstr (buf->buf, buf->len, end, sep_len); 1630 1654 } 1631 1655 cherokee/trunk/cherokee/util.h
r3403 r3423 114 114 cuint_t *sep_len); 115 115 116 ret_t cherokee_find_header_end_cstr (char *c_str, 117 cint_t c_len, 118 char **end, 119 cuint_t *sep_len); 120 116 121 ret_t cherokee_parse_host (cherokee_buffer_t *buf, 117 122 cherokee_buffer_t *host,