From 78a56cf66f3bbe29f70b19eeaff0dbc63908c677 Mon Sep 17 00:00:00 2001 From: Asra Ali Date: Mon, 18 May 2020 17:07:38 -0400 Subject: [PATCH] fix ubsan errors Signed-off-by: Asra Ali --- lib/nghttp2_buf.c | 6 ++++-- lib/nghttp2_frame.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/nghttp2_buf.c b/lib/nghttp2_buf.c index 2a435beb..a3284471 100644 --- a/lib/nghttp2_buf.c +++ b/lib/nghttp2_buf.c @@ -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) { - buf->begin = buf->pos = buf->last = buf->mark = begin; - buf->end = begin + len; + buf->begin = buf->pos = buf->last = buf->mark = buf->end = begin; + if (len) { + buf->end += len; + } } static int buf_chain_new(nghttp2_buf_chain **chain, size_t chunk_length, diff --git a/lib/nghttp2_frame.c b/lib/nghttp2_frame.c index 4821de40..86dcf9e2 100644 --- a/lib/nghttp2_frame.c +++ b/lib/nghttp2_frame.c @@ -818,8 +818,10 @@ int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame, size_t len = 0; origin = frame->payload; - p = payload; - end = p + payloadlen; + p = end = payload; + if (payloadlen) { + end += payloadlen; + } for (; p != end;) { if (end - p < 2) {