diff --git a/lib/nghttp2_frame.c b/lib/nghttp2_frame.c index 6cdcf3ec..f365984f 100644 --- a/lib/nghttp2_frame.c +++ b/lib/nghttp2_frame.c @@ -669,7 +669,8 @@ ssize_t nghttp2_frame_add_pad(uint8_t **buf_ptr, size_t *buflen_ptr, { int rv; size_t nextlen = - nghttp2_min((payloadlen + boundary - 1) / boundary * boundary, + nghttp2_min(((payloadlen == 0 ? 1 : payloadlen) + boundary - 1) + / boundary * boundary, payloadmax); size_t padlen = nextlen - payloadlen; size_t trail_padlen = 0; diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 52fa3267..0bfa2ede 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -4227,8 +4227,7 @@ ssize_t nghttp2_session_pack_data(nghttp2_session *session, frame->hd.flags &= ~(NGHTTP2_FLAG_PAD_HIGH | NGHTTP2_FLAG_PAD_LOW); flags = 0; - if(session->padding_boundary && - payloadlen > 0 && (size_t)payloadlen < datamax) { + if(session->padding_boundary && (size_t)payloadlen < datamax) { rv = nghttp2_frame_add_pad(buf_ptr, buflen_ptr, bufoff_ptr, &flags, payloadlen, datamax, session->padding_boundary);