修复残留数据,造成select_padding函数段错误
This commit is contained in:
@@ -372,38 +372,33 @@ int deflate_write(struct z_stream_st **strm, const uint8_t *source,
|
|||||||
void inflate_finished(struct z_stream_st **strm)
|
void inflate_finished(struct z_stream_st **strm)
|
||||||
{
|
{
|
||||||
if (*strm != NULL){
|
if (*strm != NULL){
|
||||||
if ((*strm)->brdec_state){
|
if ((*strm)->brdec_state)
|
||||||
|
{
|
||||||
BrotliDecoderDestroyInstance((*strm)->brdec_state);
|
BrotliDecoderDestroyInstance((*strm)->brdec_state);
|
||||||
(*strm)->brdec_state = NULL;
|
(*strm)->brdec_state = NULL;
|
||||||
return;
|
goto finish;
|
||||||
}
|
}
|
||||||
(void)inflateEnd(&((*strm)->zst));
|
(void)inflateEnd(&((*strm)->zst));
|
||||||
|
finish:
|
||||||
free(*strm);
|
free(*strm);
|
||||||
*strm = NULL;
|
*strm = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void deflate_finished(struct z_stream_st **strm)
|
void deflate_finished(struct z_stream_st **strm)
|
||||||
{
|
{
|
||||||
if (*strm != NULL){
|
if (*strm != NULL)
|
||||||
|
{
|
||||||
|
if ((*strm)->brenc_state)
|
||||||
|
{
|
||||||
|
BrotliEncoderDestroyInstance((*strm)->brenc_state);
|
||||||
|
(*strm)->brenc_state = NULL;
|
||||||
|
goto finish;
|
||||||
|
|
||||||
|
}
|
||||||
(void) deflateEnd(&((*strm)->zst));
|
(void) deflateEnd(&((*strm)->zst));
|
||||||
|
finish:
|
||||||
free(*strm);
|
free(*strm);
|
||||||
*strm = NULL;
|
*strm = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void frame_display(const uint8_t *payload, uint16_t payload_len)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
printf("context:(%d)\n", payload_len);
|
|
||||||
for(i=0; i < (int)payload_len; ++i){
|
|
||||||
printf(" 0x%02x,", payload[i]);
|
|
||||||
if( (i + 1) % 16 == 0)
|
|
||||||
printf("\n");
|
|
||||||
if ( i > 500)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1056,19 +1056,17 @@ nghttp2_submit_frame_ping(struct tfe_h2_stream *connection,const nghttp2_frame *
|
|||||||
|
|
||||||
nghttp2_session *ngh2_session = tfe_h2_stream_get_nghttp2_session(connection, dir);
|
nghttp2_session *ngh2_session = tfe_h2_stream_get_nghttp2_session(connection, dir);
|
||||||
|
|
||||||
rv = nghttp2_submit_ping(ngh2_session, ping->hd.flags,
|
rv = nghttp2_submit_ping(ngh2_session, ping->hd.flags, ping->opaque_data);
|
||||||
ping->opaque_data);
|
if (rv != 0)
|
||||||
if (rv != 0){
|
{
|
||||||
stream_action = ACTION_FORWARD_DATA;
|
stream_action = ACTION_FORWARD_DATA;
|
||||||
TFE_LOG_ERROR(logger()->handle, "dir(%d), Submit ping error: %s\n",
|
TFE_LOG_ERROR(logger()->handle, "dir(%d), Submit ping error: %s\n", dir, nghttp2_strerror(rv));
|
||||||
dir, nghttp2_strerror(rv));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
xret = nghttp2_session_send(ngh2_session);
|
xret = nghttp2_session_send(ngh2_session);
|
||||||
if (xret != 0) {
|
if (xret != 0) {
|
||||||
stream_action = ACTION_FORWARD_DATA;
|
stream_action = ACTION_FORWARD_DATA;
|
||||||
TFE_LOG_ERROR(logger()->handle, "dir(%d), Fatal send error: %s\n",
|
TFE_LOG_ERROR(logger()->handle, "dir(%d), Fatal send error: %s\n", dir, nghttp2_strerror(xret));
|
||||||
dir, nghttp2_strerror(xret));
|
|
||||||
}
|
}
|
||||||
connection->stream_action = stream_action;
|
connection->stream_action = stream_action;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1842,7 +1840,8 @@ nghttp2_client_submit_header(struct tfe_h2_stream *h2_stream_info, int32_t strea
|
|||||||
assert(h2_session->ngh2_stream_id == stream_id);
|
assert(h2_session->ngh2_stream_id == stream_id);
|
||||||
|
|
||||||
req = h2_session->req;
|
req = h2_session->req;
|
||||||
fill_req_spec_from_handle(h2_session->req);
|
fill_req_spec_from_handle(h2_session->req);
|
||||||
|
h2_stream_info->as_client->last_sent_stream_id = MIN(h2_stream_info->as_client->last_sent_stream_id, stream_id) - 1;
|
||||||
|
|
||||||
req->event_cb(req, EV_HTTP_REQ_HDR, NULL, 0, req->event_cb_user);
|
req->event_cb(req, EV_HTTP_REQ_HDR, NULL, 0, req->event_cb_user);
|
||||||
|
|
||||||
@@ -2260,15 +2259,15 @@ static ssize_t nghttp2_client_select_padding_callback(nghttp2_session *session,
|
|||||||
size_t max_payloadlen, void *user_data)
|
size_t max_payloadlen, void *user_data)
|
||||||
{
|
{
|
||||||
struct tfe_h2_half_private *resp = NULL;
|
struct tfe_h2_half_private *resp = NULL;
|
||||||
struct tfe_h2_session *h2_session = NULL;
|
struct tfe_h2_stream *h2_stream_info = (struct tfe_h2_stream *)user_data;
|
||||||
|
|
||||||
h2_session = (struct tfe_h2_session *)nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
|
struct tfe_h2_session *h2_session = TAILQ_LIST_FIND(h2_stream_info, frame->hd.stream_id);
|
||||||
if (!h2_session)
|
if (h2_session == NULL) return frame->hd.length;
|
||||||
return frame->hd.length;
|
|
||||||
resp = h2_session->resp;
|
resp = h2_session->resp;
|
||||||
if (!resp)
|
if (resp == NULL)
|
||||||
return frame->hd.length;
|
return frame->hd.length;
|
||||||
|
|
||||||
return (ssize_t)MIN(max_payloadlen, frame->hd.length + (resp->h2_payload.padlen));
|
return (ssize_t)MIN(max_payloadlen, frame->hd.length + (resp->h2_payload.padlen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user