parse the body and return data address and length */
| 802 | |
| 803 | /* parse the body and return data address and length */ |
| 804 | apr_status_t ajp_parse_data(request_rec *r, ajp_msg_t *msg, |
| 805 | apr_uint16_t *len, char **ptr) |
| 806 | { |
| 807 | apr_byte_t result; |
| 808 | apr_status_t rc; |
| 809 | apr_uint16_t expected_len; |
| 810 | |
| 811 | rc = ajp_msg_get_uint8(msg, &result); |
| 812 | if (rc != APR_SUCCESS) { |
| 813 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00996) |
| 814 | "ajp_parse_data: ajp_msg_get_byte failed"); |
| 815 | return rc; |
| 816 | } |
| 817 | if (result != CMD_AJP13_SEND_BODY_CHUNK) { |
| 818 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00997) |
| 819 | "ajp_parse_data: wrong type %s (0x%02x) expecting %s (0x%02x)", |
| 820 | ajp_type_str(result), result, |
| 821 | ajp_type_str(CMD_AJP13_SEND_BODY_CHUNK), CMD_AJP13_SEND_BODY_CHUNK); |
| 822 | return AJP_EBAD_HEADER; |
| 823 | } |
| 824 | rc = ajp_msg_get_uint16(msg, len); |
| 825 | if (rc != APR_SUCCESS) { |
| 826 | return rc; |
| 827 | } |
| 828 | /* |
| 829 | * msg->len contains the complete length of the message including all |
| 830 | * headers. So the expected length for a CMD_AJP13_SEND_BODY_CHUNK is |
| 831 | * msg->len minus the sum of |
| 832 | * AJP_HEADER_LEN : The length of the header to every AJP message. |
| 833 | * AJP_HEADER_SZ_LEN : The header giving the size of the chunk. |
| 834 | * 1 : The CMD_AJP13_SEND_BODY_CHUNK indicator byte (0x03). |
| 835 | * 1 : The last byte of this message always seems to be |
| 836 | * 0x00 and is not part of the chunk. |
| 837 | */ |
| 838 | if (msg->len < AJP_HEADER_LEN + AJP_HEADER_SZ_LEN + 1 + 1) { |
| 839 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10546) |
| 840 | "ajp_parse_data: Message too small"); |
| 841 | return AJP_EBAD_HEADER; |
| 842 | } |
| 843 | expected_len = msg->len - (AJP_HEADER_LEN + AJP_HEADER_SZ_LEN + 1 + 1); |
| 844 | if (*len != expected_len) { |
| 845 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00998) |
| 846 | "ajp_parse_data: Wrong chunk length. Length of chunk is %i," |
| 847 | " expected length is %i.", *len, expected_len); |
| 848 | return AJP_EBAD_HEADER; |
| 849 | } |
| 850 | *ptr = (char *)&(msg->buf[msg->pos]); |
| 851 | return APR_SUCCESS; |
| 852 | } |
| 853 | |
| 854 | /* Check the reuse flag in CMD_AJP13_END_RESPONSE */ |
| 855 | apr_status_t ajp_parse_reuse(request_rec *r, ajp_msg_t *msg, |
no test coverage detected