fix ubsan errors

Signed-off-by: Asra Ali <asraa@google.com>
This commit is contained in:
Asra Ali 2020-05-18 17:07:38 -04:00 committed by Tatsuhiro Tsujikawa
parent ec084acdba
commit 78a56cf66f
2 changed files with 8 additions and 4 deletions

View File

@ -82,8 +82,10 @@ void nghttp2_buf_reset(nghttp2_buf *buf) {
} }
void nghttp2_buf_wrap_init(nghttp2_buf *buf, uint8_t *begin, size_t len) { void nghttp2_buf_wrap_init(nghttp2_buf *buf, uint8_t *begin, size_t len) {
buf->begin = buf->pos = buf->last = buf->mark = begin; buf->begin = buf->pos = buf->last = buf->mark = buf->end = begin;
buf->end = begin + len; if (len) {
buf->end += len;
}
} }
static int buf_chain_new(nghttp2_buf_chain **chain, size_t chunk_length, static int buf_chain_new(nghttp2_buf_chain **chain, size_t chunk_length,

View File

@ -818,8 +818,10 @@ int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame,
size_t len = 0; size_t len = 0;
origin = frame->payload; origin = frame->payload;
p = payload; p = end = payload;
end = p + payloadlen; if (payloadlen) {
end += payloadlen;
}
for (; p != end;) { for (; p != end;) {
if (end - p < 2) { if (end - p < 2) {