842 | 842 |
}
|
843 | 843 |
if (connp->in_next_byte != LF || connp->in_current_consume_offset >= connp->in_current_read_offset) {
|
844 | 844 |
for (;;) {//;i < max_read; i++) {
|
845 | |
IN_COPY_BYTE_OR_RETURN(connp);
|
846 | |
// Have we reached the end of the line? For some reason
|
847 | |
// we can't test after IN_COPY_BYTE_OR_RETURN */
|
|
845 |
// peek until LF but do not mark it read so that REQ_LINE works
|
|
846 |
IN_PEEK_NEXT(connp);
|
848 | 847 |
if (connp->in_next_byte == LF)
|
849 | 848 |
break;
|
|
849 |
IN_COPY_BYTE_OR_RETURN(connp);
|
850 | 850 |
}
|
851 | 851 |
}
|
852 | 852 |
}
|
|
876 | 876 |
while ((pos < len) && (!htp_is_space(data[pos])))
|
877 | 877 |
pos++;
|
878 | 878 |
|
879 | |
if (pos <= mstart) {
|
880 | |
//empty whitespace line
|
881 | |
htp_status_t rc = htp_tx_req_process_body_data_ex(connp->in_tx, data, len);
|
882 | |
htp_connp_req_clear_buffer(connp);
|
883 | |
return rc;
|
884 | |
} else {
|
|
879 |
if (pos > mstart) {
|
|
880 |
//non empty whitespace line
|
885 | 881 |
int methodi = HTP_M_UNKNOWN;
|
886 | 882 |
bstr *method = bstr_dup_mem(data + mstart, pos - mstart);
|
887 | 883 |
if (method) {
|
888 | 884 |
methodi = htp_convert_method_to_number(method);
|
889 | 885 |
bstr_free(method);
|
890 | 886 |
}
|
891 | |
if (methodi == HTP_M_UNKNOWN) {
|
892 | |
if (connp->in_body_data_left <= 0) {
|
893 | |
// log only once per transaction
|
894 | |
htp_log(connp, HTP_LOG_MARK, HTP_LOG_WARNING, 0, "Unexpected request body");
|
895 | |
} else {
|
896 | |
connp->in_body_data_left = 1;
|
897 | |
}
|
898 | |
// Interpret remaining bytes as body data
|
899 | |
htp_status_t rc = htp_tx_req_process_body_data_ex(connp->in_tx, data, len);
|
900 | |
htp_connp_req_clear_buffer(connp);
|
901 | |
return rc;
|
|
887 |
if (methodi != HTP_M_UNKNOWN) {
|
|
888 |
connp->in_body_data_left = -1;
|
|
889 |
return htp_tx_state_request_complete(connp->in_tx);
|
902 | 890 |
} // else continue
|
903 | |
connp->in_body_data_left = -1;
|
904 | |
}
|
905 | |
//unread last end of line so that REQ_LINE works
|
906 | |
if (connp->in_current_read_offset < (int64_t)len) {
|
907 | |
connp->in_current_read_offset=0;
|
908 | |
} else {
|
909 | |
connp->in_current_read_offset-=len;
|
910 | |
}
|
911 | |
if (connp->in_current_read_offset < connp->in_current_consume_offset) {
|
912 | |
connp->in_current_consume_offset=connp->in_current_read_offset;
|
913 | |
}
|
914 | |
|
915 | |
return htp_tx_state_request_complete(connp->in_tx);
|
|
891 |
if (connp->in_body_data_left <= 0) {
|
|
892 |
// log only once per transaction
|
|
893 |
htp_log(connp, HTP_LOG_MARK, HTP_LOG_WARNING, 0, "Unexpected request body");
|
|
894 |
} else {
|
|
895 |
connp->in_body_data_left = 1;
|
|
896 |
}
|
|
897 |
}
|
|
898 |
//Adds linefeed to the buffer if there was one
|
|
899 |
if (connp->in_next_byte == LF) {
|
|
900 |
IN_COPY_BYTE_OR_RETURN(connp);
|
|
901 |
htp_connp_req_consolidate_data(connp, &data, &len);
|
|
902 |
}
|
|
903 |
// Interpret remaining bytes as body data
|
|
904 |
htp_status_t rc = htp_tx_req_process_body_data_ex(connp->in_tx, data, len);
|
|
905 |
htp_connp_req_clear_buffer(connp);
|
|
906 |
return rc;
|
916 | 907 |
}
|
917 | 908 |
|
918 | 909 |
htp_status_t htp_connp_REQ_IGNORE_DATA_AFTER_HTTP_0_9(htp_connp_t *connp) {
|