tiny-nghttpd: Remove validations offered by lib

This commit is contained in:
Tatsuhiro Tsujikawa 2015-02-20 20:58:11 +09:00
parent 83d9ee1fd1
commit 2216fd2bc1
1 changed files with 1 additions and 34 deletions

View File

@ -925,8 +925,7 @@ static int on_header_callback(nghttp2_session *session,
const nghttp2_frame *frame, const uint8_t *name, const nghttp2_frame *frame, const uint8_t *name,
size_t namelen, const uint8_t *value, size_t namelen, const uint8_t *value,
size_t valuelen, uint8_t flags _U_, size_t valuelen, uint8_t flags _U_,
void *user_data) { void *user_data _U_) {
connection *conn = user_data;
stream *strm; stream *strm;
if (frame->hd.type != NGHTTP2_HEADERS || if (frame->hd.type != NGHTTP2_HEADERS ||
@ -940,16 +939,7 @@ static int on_header_callback(nghttp2_session *session,
return 0; return 0;
} }
if (!nghttp2_check_header_name(name, namelen) ||
!nghttp2_check_header_value(value, valuelen)) {
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
if (memseq(name, namelen, ":method")) { if (memseq(name, namelen, ":method")) {
if (strm->method) {
stream_error(conn, strm->stream_id, NGHTTP2_PROTOCOL_ERROR);
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
strm->method = io_buf_add_str(&strm->scrbuf, value, valuelen); strm->method = io_buf_add_str(&strm->scrbuf, value, valuelen);
if (!strm->method) { if (!strm->method) {
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
@ -959,10 +949,6 @@ static int on_header_callback(nghttp2_session *session,
} }
if (memseq(name, namelen, ":scheme")) { if (memseq(name, namelen, ":scheme")) {
if (strm->scheme) {
stream_error(conn, strm->stream_id, NGHTTP2_PROTOCOL_ERROR);
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
strm->scheme = io_buf_add_str(&strm->scrbuf, value, valuelen); strm->scheme = io_buf_add_str(&strm->scrbuf, value, valuelen);
if (!strm->scheme) { if (!strm->scheme) {
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
@ -972,10 +958,6 @@ static int on_header_callback(nghttp2_session *session,
} }
if (memseq(name, namelen, ":authority")) { if (memseq(name, namelen, ":authority")) {
if (strm->authority) {
stream_error(conn, strm->stream_id, NGHTTP2_PROTOCOL_ERROR);
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
strm->authority = io_buf_add_str(&strm->scrbuf, value, valuelen); strm->authority = io_buf_add_str(&strm->scrbuf, value, valuelen);
if (!strm->authority) { if (!strm->authority) {
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
@ -985,10 +967,6 @@ static int on_header_callback(nghttp2_session *session,
} }
if (memseq(name, namelen, ":path")) { if (memseq(name, namelen, ":path")) {
if (strm->path) {
stream_error(conn, strm->stream_id, NGHTTP2_PROTOCOL_ERROR);
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
strm->path = io_buf_add_str(&strm->scrbuf, value, valuelen); strm->path = io_buf_add_str(&strm->scrbuf, value, valuelen);
if (!strm->path) { if (!strm->path) {
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
@ -997,11 +975,6 @@ static int on_header_callback(nghttp2_session *session,
return 0; return 0;
} }
if (name[0] == ':') {
stream_error(conn, strm->stream_id, NGHTTP2_PROTOCOL_ERROR);
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
if (memseq(name, namelen, "host") && !strm->host) { if (memseq(name, namelen, "host") && !strm->host) {
strm->host = io_buf_add_str(&strm->scrbuf, value, valuelen); strm->host = io_buf_add_str(&strm->scrbuf, value, valuelen);
if (!strm->host) { if (!strm->host) {
@ -1029,12 +1002,6 @@ static int on_frame_recv_callback(nghttp2_session *session,
return 0; return 0;
} }
if (!strm->method || !strm->scheme || !strm->path ||
(!strm->authority && !strm->host)) {
stream_error(conn, strm->stream_id, NGHTTP2_PROTOCOL_ERROR);
return 0;
}
if (!strm->host) { if (!strm->host) {
strm->host = strm->authority; strm->host = strm->authority;
strm->hostlen = strm->authoritylen; strm->hostlen = strm->authoritylen;