From f433b6b5e9d54279e85be041b2101f4365ce76bb Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Date: Mon, 17 Aug 2020 00:33:41 +0900 Subject: [PATCH] Fix assertion --- examples/h09client.cc | 9 +++++---- examples/h09client.h | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/h09client.cc b/examples/h09client.cc index 19b3fbea..5fbfc0f7 100644 --- a/examples/h09client.cc +++ b/examples/h09client.cc @@ -510,7 +510,7 @@ int acked_stream_data_offset(ngtcp2_conn *conn, int64_t stream_id, uint64_t offset, uint64_t datalen, void *user_data, void *stream_user_data) { auto c = static_cast<Client *>(user_data); - if (c->acked_stream_data_offset(stream_id, datalen) != 0) { + if (c->acked_stream_data_offset(stream_id, offset, datalen) != 0) { return NGTCP2_ERR_CALLBACK_FAILURE; } return 0; @@ -1651,12 +1651,13 @@ int Client::recv_stream_data(uint32_t flags, int64_t stream_id, return 0; } -int Client::acked_stream_data_offset(int64_t stream_id, uint64_t datalen) { +int Client::acked_stream_data_offset(int64_t stream_id, uint64_t offset, + uint64_t datalen) { auto it = streams_.find(stream_id); assert(it != std::end(streams_)); auto &stream = (*it).second; - assert(static_cast<uint64_t>(stream->reqbuf.end - stream->reqbuf.begin) <= - datalen); + assert(static_cast<uint64_t>(stream->reqbuf.end - stream->reqbuf.begin) >= + offset + datalen); return 0; } diff --git a/examples/h09client.h b/examples/h09client.h index 08658387..3181e089 100644 --- a/examples/h09client.h +++ b/examples/h09client.h @@ -266,7 +266,8 @@ public: int submit_http_request(Stream *stream); int recv_stream_data(uint32_t flags, int64_t stream_id, const uint8_t *data, size_t datalen); - int acked_stream_data_offset(int64_t stream_id, uint64_t datalen); + int acked_stream_data_offset(int64_t stream_id, uint64_t offset, + uint64_t datalen); int extend_max_stream_data(int64_t stream_id, uint64_t max_data); void reset_idle_timer(); -- GitLab