Skip to content

Commit

Permalink
http2: fix incorrect trailer buffer size
Browse files Browse the repository at this point in the history
Prior to this change the stored byte count of each trailer was
miscalculated and 1 less than required. It appears any trailer
after the first that was passed to Curl_client_write would be truncated
or corrupted as well as the size. Potentially the size of some
subsequent trailer could be erroneously extracted from the contents of
that trailer, and since that size is used by client write an
out-of-bounds read could occur and cause a crash or be otherwise
processed by client write.

The bug appears to have been born in 0761a51 (precedes 7.49.0).

Closes #2231
  • Loading branch information
Zhouyihai Ding authored and jay committed Jan 11, 2018
1 parent 2a6dbb8 commit fa3dbb9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/http2.c
Expand Up @@ -925,8 +925,8 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,

if(stream->bodystarted) {
/* This is trailer fields. */
/* 3 is for ":" and "\r\n". */
uint32_t n = (uint32_t)(namelen + valuelen + 3);
/* 4 is for ": " and "\r\n". */
uint32_t n = (uint32_t)(namelen + valuelen + 4);

DEBUGF(infof(data_s, "h2 trailer: %.*s: %.*s\n", namelen, name, valuelen,
value));
Expand Down

0 comments on commit fa3dbb9

Please sign in to comment.