Skip to content

Commit fb6a7c8

Browse files
committed
coverity 472861: http2: deal with zero length data without overflow
1 parent aff5bb4 commit fb6a7c8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/roles/h2/http2.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,12 +2329,14 @@ lws_h2_parser(struct lws *wsi, unsigned char *in, lws_filepos_t _inlen,
23292329
(unsigned int)h2n->count,
23302330
(unsigned int)h2n->length);
23312331

2332-
in += (unsigned int)n - 1;
2333-
h2n->inside += (unsigned int)n;
2334-
h2n->count += (unsigned int)n - 1;
2332+
if (n) {
2333+
in += (unsigned int)n - 1;
2334+
h2n->inside += (unsigned int)n;
2335+
h2n->count += (unsigned int)n - 1;
23352336

2336-
h2n->swsi->txc.peer_tx_cr_est -= n;
2337-
wsi->txc.peer_tx_cr_est -= n;
2337+
h2n->swsi->txc.peer_tx_cr_est -= n;
2338+
wsi->txc.peer_tx_cr_est -= n;
2339+
}
23382340

23392341
do_windows:
23402342

0 commit comments

Comments
 (0)