Skip to content

Commit 113deb1

Browse files
deps: update nghttp3 to 1.19.0
1 parent ae353ec commit 113deb1

14 files changed

Lines changed: 192 additions & 178 deletions

‎deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,12 +1871,13 @@ typedef struct nghttp3_settings {
18711871
NGHTTP3_SETTINGS_V3. */
18721872
/**
18731873
* :member:`glitch_ratelim_burst` is the maximum number of tokens
1874-
* available to "glitch" rate limiter. "glitch" is a suspicious
1875-
* activity from a remote endpoint. If detected, certain amount of
1876-
* tokens are consumed. If no tokens are available to consume, the
1877-
* connection is closed. The rate of token generation is specified
1878-
* by :member:`glitch_ratelim_rate`. This feature is enabled only
1879-
* when `nghttp3_conn_read_stream2` is used.
1874+
* available to "glitch" rate limiter. It is clamped to UINT64_MAX
1875+
* / NGHTTP3_SECONDS. "glitch" is a suspicious activity from a
1876+
* remote endpoint. If detected, certain amount of tokens are
1877+
* consumed. If no tokens are available to consume, the connection
1878+
* is closed. The rate of token generation is specified by
1879+
* :member:`glitch_ratelim_rate`. This feature is enabled only when
1880+
* `nghttp3_conn_read_stream2` is used.
18801881
*
18811882
* .. version-added:: 1.12.0
18821883
*/
@@ -3089,6 +3090,8 @@ typedef struct nghttp3_data_reader {
30893090
* Stream has already been opened.
30903091
* :macro:`NGHTTP3_ERR_NOMEM`
30913092
* Out of memory.
3093+
* :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
3094+
* The required memory for |nva| of length |nvlen| is too large.
30923095
*/
30933096
NGHTTP3_EXTERN int nghttp3_conn_submit_request(
30943097
nghttp3_conn *conn, int64_t stream_id, const nghttp3_nv *nva, size_t nvlen,
@@ -3108,6 +3111,8 @@ NGHTTP3_EXTERN int nghttp3_conn_submit_request(
31083111
* Stream not found
31093112
* :macro:`NGHTTP3_ERR_NOMEM`
31103113
* Out of memory.
3114+
* :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
3115+
* The required memory for |nva| of length |nvlen| is too large.
31113116
*/
31123117
NGHTTP3_EXTERN int nghttp3_conn_submit_info(nghttp3_conn *conn,
31133118
int64_t stream_id,
@@ -3130,6 +3135,8 @@ NGHTTP3_EXTERN int nghttp3_conn_submit_info(nghttp3_conn *conn,
31303135
* Stream not found
31313136
* :macro:`NGHTTP3_ERR_NOMEM`
31323137
* Out of memory.
3138+
* :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
3139+
* The required memory for |nva| of length |nvlen| is too large.
31333140
*/
31343141
NGHTTP3_EXTERN int nghttp3_conn_submit_response(nghttp3_conn *conn,
31353142
int64_t stream_id,
@@ -3154,6 +3161,8 @@ NGHTTP3_EXTERN int nghttp3_conn_submit_response(nghttp3_conn *conn,
31543161
* Application has already submitted fin to stream.
31553162
* :macro:`NGHTTP3_ERR_NOMEM`
31563163
* Out of memory.
3164+
* :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
3165+
* The required memory for |nva| of length |nvlen| is too large.
31573166
*/
31583167
NGHTTP3_EXTERN int nghttp3_conn_submit_trailers(nghttp3_conn *conn,
31593168
int64_t stream_id,

‎deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* Version number of the nghttp3 library release.
3333
*/
34-
#define NGHTTP3_VERSION "1.18.0"
34+
#define NGHTTP3_VERSION "1.19.0"
3535

3636
/**
3737
* @macro
@@ -41,6 +41,6 @@
4141
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
4242
* becomes 0x010203.
4343
*/
44-
#define NGHTTP3_VERSION_NUM 0x011200
44+
#define NGHTTP3_VERSION_NUM 0x011300
4545

4646
#endif /* !defined(NGHTTP3_VERSION_H) */

‎deps/ngtcp2/nghttp3/lib/nghttp3_balloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int nghttp3_balloc_get(nghttp3_balloc *balloc, void **pbuf, size_t n) {
6767

6868
if (nghttp3_buf_left(&balloc->buf) < n) {
6969
p = nghttp3_mem_malloc(balloc->mem,
70-
sizeof(nghttp3_memblock_hd) + 0x8U + balloc->blklen);
70+
sizeof(nghttp3_memblock_hd) + 0xFU + balloc->blklen);
7171
if (p == NULL) {
7272
return NGHTTP3_ERR_NOMEM;
7373
}

‎deps/ngtcp2/nghttp3/lib/nghttp3_buf.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
*/
2626
#include "nghttp3_buf.h"
2727

28-
void nghttp3_buf_init(nghttp3_buf *buf) {
29-
buf->begin = buf->end = buf->pos = buf->last = NULL;
30-
}
28+
void nghttp3_buf_init(nghttp3_buf *buf) { *buf = (nghttp3_buf){0}; }
3129

3230
void nghttp3_buf_wrap_init(nghttp3_buf *buf, uint8_t *src, size_t len) {
33-
buf->begin = buf->pos = buf->last = src;
34-
buf->end = buf->begin + len;
31+
*buf = (nghttp3_buf){
32+
.begin = src,
33+
.end = src + len,
34+
.pos = src,
35+
.last = src,
36+
};
3537
}
3638

3739
void nghttp3_buf_free(nghttp3_buf *buf, const nghttp3_mem *mem) {

‎deps/ngtcp2/nghttp3/lib/nghttp3_conn.c‎

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,14 @@ nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn, int64_t stream_id,
555555
return 0;
556556
}
557557

558+
if (fin) {
559+
stream->flags |= NGHTTP3_STREAM_FLAG_READ_EOF;
560+
}
561+
558562
if (nghttp3_stream_uni(stream_id)) {
559563
return nghttp3_conn_read_uni(conn, stream, src, srclen, fin, ts);
560564
}
561565

562-
if (fin) {
563-
stream->flags |= NGHTTP3_STREAM_FLAG_READ_EOF;
564-
}
565566
return nghttp3_conn_read_bidi(conn, &bidi_nproc, stream, src, srclen, fin,
566567
ts);
567568
}
@@ -1126,6 +1127,13 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
11261127
break;
11271128
}
11281129

1130+
/* Apply buffer limits here even if everything is in the input
1131+
buffer. */
1132+
if (rstate->left > sizeof(conn->rx.pri_fieldbuf)) {
1133+
rstate->state = NGHTTP3_CTRL_STREAM_STATE_IGN_FRAME;
1134+
break;
1135+
}
1136+
11291137
conn->rx.pri_fieldbuflen = 0;
11301138

11311139
rstate->state = NGHTTP3_CTRL_STREAM_STATE_PRIORITY_UPDATE;
@@ -1141,22 +1149,12 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
11411149
len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p));
11421150
assert(len > 0);
11431151
if (conn->rx.pri_fieldbuflen == 0 && rstate->left == len) {
1144-
/* Everything is in the input buffer. Apply same length
1145-
limit we impose when buffering the field. */
1146-
if (len > sizeof(conn->rx.pri_fieldbuf)) {
1147-
busy = 1;
1148-
rstate->state = NGHTTP3_CTRL_STREAM_STATE_IGN_FRAME;
1149-
break;
1150-
}
1151-
1152+
/* Everything is in the input buffer. */
11521153
pri_field_value = p;
11531154
pri_field_valuelen = len;
1154-
} else if (len + conn->rx.pri_fieldbuflen >
1155-
sizeof(conn->rx.pri_fieldbuf)) {
1156-
busy = 1;
1157-
rstate->state = NGHTTP3_CTRL_STREAM_STATE_IGN_FRAME;
1158-
break;
11591155
} else {
1156+
assert(len + conn->rx.pri_fieldbuflen <= sizeof(conn->rx.pri_fieldbuf));
1157+
11601158
memcpy(conn->rx.pri_fieldbuf + conn->rx.pri_fieldbuflen, p, len);
11611159
conn->rx.pri_fieldbuflen += len;
11621160

@@ -1975,6 +1973,12 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn,
19751973
break;
19761974
}
19771975

1976+
#if SIZE_MAX < UINT64_MAX
1977+
if (ent->value > SIZE_MAX) {
1978+
return NGHTTP3_ERR_H3_SETTINGS_ERROR;
1979+
}
1980+
#endif /* SIZE_MAX < UINT64_MAX */
1981+
19781982
dest->qpack_max_dtable_capacity = (size_t)ent->value;
19791983

19801984
nghttp3_qpack_encoder_set_max_dtable_capacity(&conn->qenc,
@@ -1989,6 +1993,12 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn,
19891993
break;
19901994
}
19911995

1996+
#if SIZE_MAX < UINT64_MAX
1997+
if (ent->value > SIZE_MAX) {
1998+
return NGHTTP3_ERR_H3_SETTINGS_ERROR;
1999+
}
2000+
#endif /* SIZE_MAX < UINT64_MAX */
2001+
19922002
dest->qpack_blocked_streams = (size_t)ent->value;
19932003

19942004
nghttp3_qpack_encoder_set_max_blocked_streams(
@@ -2957,6 +2967,8 @@ int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn,
29572967
memcpy(buf, data, datalen);
29582968
}
29592969

2970+
assert(conn->tx.ctrl);
2971+
29602972
rv = nghttp3_stream_frq_emplace(conn->tx.ctrl, &fr);
29612973
if (rv != 0) {
29622974
nghttp3_mem_free(conn->mem, buf);

‎deps/ngtcp2/nghttp3/lib/nghttp3_frame.c‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ size_t nghttp3_frame_write_origin_len(uint64_t *ppayloadlen,
136136
int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen,
137137
const nghttp3_mem *mem) {
138138
size_t i;
139-
uint8_t *data = NULL;
140-
size_t buflen = 0;
139+
uint8_t *data;
140+
size_t buflen;
141141
nghttp3_nv *p;
142142

143143
if (nvlen == 0) {
@@ -146,18 +146,32 @@ int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen,
146146
return 0;
147147
}
148148

149+
if (sizeof(nghttp3_nv) > SIZE_MAX / nvlen) {
150+
return NGHTTP3_ERR_INVALID_ARGUMENT;
151+
}
152+
153+
buflen = sizeof(nghttp3_nv) * nvlen;
154+
149155
for (i = 0; i < nvlen; ++i) {
150156
/* + 1 for null-termination */
151157
if ((nva[i].flags & NGHTTP3_NV_FLAG_NO_COPY_NAME) == 0) {
158+
if (nva[i].namelen == SIZE_MAX ||
159+
buflen > SIZE_MAX - nva[i].namelen - 1) {
160+
return NGHTTP3_ERR_INVALID_ARGUMENT;
161+
}
162+
152163
buflen += nva[i].namelen + 1;
153164
}
154165
if ((nva[i].flags & NGHTTP3_NV_FLAG_NO_COPY_VALUE) == 0) {
166+
if (nva[i].valuelen == SIZE_MAX ||
167+
buflen > SIZE_MAX - nva[i].valuelen - 1) {
168+
return NGHTTP3_ERR_INVALID_ARGUMENT;
169+
}
170+
155171
buflen += nva[i].valuelen + 1;
156172
}
157173
}
158174

159-
buflen += sizeof(nghttp3_nv) * nvlen;
160-
161175
*pnva = nghttp3_mem_malloc(mem, buflen);
162176

163177
if (*pnva == NULL) {
@@ -169,30 +183,28 @@ int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen,
169183

170184
for (i = 0; i < nvlen; ++i) {
171185
p->flags = nva[i].flags;
186+
p->namelen = nva[i].namelen;
187+
p->valuelen = nva[i].valuelen;
172188

173189
if (nva[i].flags & NGHTTP3_NV_FLAG_NO_COPY_NAME) {
174190
p->name = nva[i].name;
175-
p->namelen = nva[i].namelen;
176191
} else {
177192
if (nva[i].namelen) {
178193
memcpy(data, nva[i].name, nva[i].namelen);
179194
nghttp3_downcase(data, nva[i].namelen);
180195
}
181196
p->name = data;
182-
p->namelen = nva[i].namelen;
183197
data[p->namelen] = '\0';
184198
data += nva[i].namelen + 1;
185199
}
186200

187201
if (nva[i].flags & NGHTTP3_NV_FLAG_NO_COPY_VALUE) {
188202
p->value = nva[i].value;
189-
p->valuelen = nva[i].valuelen;
190203
} else {
191204
if (nva[i].valuelen) {
192205
memcpy(data, nva[i].value, nva[i].valuelen);
193206
}
194207
p->value = data;
195-
p->valuelen = nva[i].valuelen;
196208
data[p->valuelen] = '\0';
197209
data += nva[i].valuelen + 1;
198210
}

‎deps/ngtcp2/nghttp3/lib/nghttp3_frame.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ size_t nghttp3_frame_write_origin_len(uint64_t *ppayloadlen,
247247
*
248248
* NGHTTP3_ERR_NOMEM
249249
* Out of memory.
250+
* NGHTTP3_ERR_INVALID_ARGUMENT
251+
* The required memory for |nva| of length |nvlen| is too large.
250252
*/
251253
int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen,
252254
const nghttp3_mem *mem);

0 commit comments

Comments
 (0)