GeezerVison is showing github.com — deps: update nghttp3 to 1.19.0 · nodejs/node@a92ee33
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h +15-6Lines changed: 15 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1871,12 +1871,13 @@ typedef struct nghttp3_settings { | 1871 | 1871 | NGHTTP3_SETTINGS_V3. */ | 1872 | 1872 | /** | 1873 | 1873 | * :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. | 1880 | 1881 | * | 1881 | 1882 | * .. version-added:: 1.12.0 | 1882 | 1883 | */ | @@ -3089,6 +3090,8 @@ typedef struct nghttp3_data_reader { | 3089 | 3090 | * Stream has already been opened. | 3090 | 3091 | * :macro:`NGHTTP3_ERR_NOMEM` | 3091 | 3092 | * Out of memory. | | 3093 | + * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT` | | 3094 | + * The required memory for |nva| of length |nvlen| is too large. | 3092 | 3095 | */ | 3093 | 3096 | NGHTTP3_EXTERN int nghttp3_conn_submit_request( | 3094 | 3097 | 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( | 3108 | 3111 | * Stream not found | 3109 | 3112 | * :macro:`NGHTTP3_ERR_NOMEM` | 3110 | 3113 | * Out of memory. | | 3114 | + * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT` | | 3115 | + * The required memory for |nva| of length |nvlen| is too large. | 3111 | 3116 | */ | 3112 | 3117 | NGHTTP3_EXTERN int nghttp3_conn_submit_info(nghttp3_conn *conn, | 3113 | 3118 | int64_t stream_id, | @@ -3130,6 +3135,8 @@ NGHTTP3_EXTERN int nghttp3_conn_submit_info(nghttp3_conn *conn, | 3130 | 3135 | * Stream not found | 3131 | 3136 | * :macro:`NGHTTP3_ERR_NOMEM` | 3132 | 3137 | * Out of memory. | | 3138 | + * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT` | | 3139 | + * The required memory for |nva| of length |nvlen| is too large. | 3133 | 3140 | */ | 3134 | 3141 | NGHTTP3_EXTERN int nghttp3_conn_submit_response(nghttp3_conn *conn, | 3135 | 3142 | int64_t stream_id, | @@ -3154,6 +3161,8 @@ NGHTTP3_EXTERN int nghttp3_conn_submit_response(nghttp3_conn *conn, | 3154 | 3161 | * Application has already submitted fin to stream. | 3155 | 3162 | * :macro:`NGHTTP3_ERR_NOMEM` | 3156 | 3163 | * Out of memory. | | 3164 | + * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT` | | 3165 | + * The required memory for |nva| of length |nvlen| is too large. | 3157 | 3166 | */ | 3158 | 3167 | NGHTTP3_EXTERN int nghttp3_conn_submit_trailers(nghttp3_conn *conn, | 3159 | 3168 | int64_t stream_id, | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 31 | 31 | * | 32 | 32 | * Version number of the nghttp3 library release. | 33 | 33 | */ | 34 | | -#define NGHTTP3_VERSION "1.18.0" | | 34 | +#define NGHTTP3_VERSION "1.19.0" | 35 | 35 |
| 36 | 36 | /** | 37 | 37 | * @macro | | 41 | 41 | * number, 8 bits for minor and 8 bits for patch. Version 1.2.3 | 42 | 42 | * becomes 0x010203. | 43 | 43 | */ | 44 | | -#define NGHTTP3_VERSION_NUM 0x011200 | | 44 | +#define NGHTTP3_VERSION_NUM 0x011300 | 45 | 45 |
| 46 | 46 | #endif /* !defined(NGHTTP3_VERSION_H) */ |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/nghttp3/lib/nghttp3_balloc.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -67,7 +67,7 @@ int nghttp3_balloc_get(nghttp3_balloc *balloc, void **pbuf, size_t n) { | 67 | 67 |
| 68 | 68 | if (nghttp3_buf_left(&balloc->buf) < n) { | 69 | 69 | p = nghttp3_mem_malloc(balloc->mem, | 70 | | - sizeof(nghttp3_memblock_hd) + 0x8U + balloc->blklen); | | 70 | + sizeof(nghttp3_memblock_hd) + 0xFU + balloc->blklen); | 71 | 71 | if (p == NULL) { | 72 | 72 | return NGHTTP3_ERR_NOMEM; | 73 | 73 | } | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/nghttp3/lib/nghttp3_buf.c +7-5Lines changed: 7 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 25 | 25 | */ | 26 | 26 | #include "nghttp3_buf.h" | 27 | 27 |
| 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}; } | 31 | 29 |
| 32 | 30 | 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 | + }; | 35 | 37 | } | 36 | 38 |
| 37 | 39 | void nghttp3_buf_free(nghttp3_buf *buf, const nghttp3_mem *mem) { | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/nghttp3/lib/nghttp3_conn.c +28-16Lines changed: 28 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -555,13 +555,14 @@ nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn, int64_t stream_id, | 555 | 555 | return 0; | 556 | 556 | } | 557 | 557 |
| | 558 | + if (fin) { | | 559 | + stream->flags |= NGHTTP3_STREAM_FLAG_READ_EOF; | | 560 | + } | | 561 | + | 558 | 562 | if (nghttp3_stream_uni(stream_id)) { | 559 | 563 | return nghttp3_conn_read_uni(conn, stream, src, srclen, fin, ts); | 560 | 564 | } | 561 | 565 |
| 562 | | - if (fin) { | 563 | | - stream->flags |= NGHTTP3_STREAM_FLAG_READ_EOF; | 564 | | - } | 565 | 566 | return nghttp3_conn_read_bidi(conn, &bidi_nproc, stream, src, srclen, fin, | 566 | 567 | ts); | 567 | 568 | } | @@ -1126,6 +1127,13 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, | 1126 | 1127 | break; | 1127 | 1128 | } | 1128 | 1129 |
| | 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 | + | 1129 | 1137 | conn->rx.pri_fieldbuflen = 0; | 1130 | 1138 |
| 1131 | 1139 | rstate->state = NGHTTP3_CTRL_STREAM_STATE_PRIORITY_UPDATE; | @@ -1141,22 +1149,12 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn, | 1141 | 1149 | len = (size_t)nghttp3_min(rstate->left, (uint64_t)(end - p)); | 1142 | 1150 | assert(len > 0); | 1143 | 1151 | 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. */ | 1152 | 1153 | pri_field_value = p; | 1153 | 1154 | 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; | 1159 | 1155 | } else { | | 1156 | + assert(len + conn->rx.pri_fieldbuflen <= sizeof(conn->rx.pri_fieldbuf)); | | 1157 | + | 1160 | 1158 | memcpy(conn->rx.pri_fieldbuf + conn->rx.pri_fieldbuflen, p, len); | 1161 | 1159 | conn->rx.pri_fieldbuflen += len; | 1162 | 1160 |
| @@ -1975,6 +1973,12 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn, | 1975 | 1973 | break; | 1976 | 1974 | } | 1977 | 1975 |
| | 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 | + | 1978 | 1982 | dest->qpack_max_dtable_capacity = (size_t)ent->value; | 1979 | 1983 |
| 1980 | 1984 | nghttp3_qpack_encoder_set_max_dtable_capacity(&conn->qenc, | @@ -1989,6 +1993,12 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn, | 1989 | 1993 | break; | 1990 | 1994 | } | 1991 | 1995 |
| | 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 | + | 1992 | 2002 | dest->qpack_blocked_streams = (size_t)ent->value; | 1993 | 2003 |
| 1994 | 2004 | nghttp3_qpack_encoder_set_max_blocked_streams( | @@ -2957,6 +2967,8 @@ int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn, | 2957 | 2967 | memcpy(buf, data, datalen); | 2958 | 2968 | } | 2959 | 2969 |
| | 2970 | + assert(conn->tx.ctrl); | | 2971 | + | 2960 | 2972 | rv = nghttp3_stream_frq_emplace(conn->tx.ctrl, &fr); | 2961 | 2973 | if (rv != 0) { | 2962 | 2974 | nghttp3_mem_free(conn->mem, buf); | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/nghttp3/lib/nghttp3_frame.c +20-8Lines changed: 20 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -136,8 +136,8 @@ size_t nghttp3_frame_write_origin_len(uint64_t *ppayloadlen, | 136 | 136 | int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen, | 137 | 137 | const nghttp3_mem *mem) { | 138 | 138 | size_t i; | 139 | | - uint8_t *data = NULL; | 140 | | - size_t buflen = 0; | | 139 | + uint8_t *data; | | 140 | + size_t buflen; | 141 | 141 | nghttp3_nv *p; | 142 | 142 |
| 143 | 143 | if (nvlen == 0) { | @@ -146,18 +146,32 @@ int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen, | 146 | 146 | return 0; | 147 | 147 | } | 148 | 148 |
| | 149 | + if (sizeof(nghttp3_nv) > SIZE_MAX / nvlen) { | | 150 | + return NGHTTP3_ERR_INVALID_ARGUMENT; | | 151 | + } | | 152 | + | | 153 | + buflen = sizeof(nghttp3_nv) * nvlen; | | 154 | + | 149 | 155 | for (i = 0; i < nvlen; ++i) { | 150 | 156 | /* + 1 for null-termination */ | 151 | 157 | 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 | + | 152 | 163 | buflen += nva[i].namelen + 1; | 153 | 164 | } | 154 | 165 | 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 | + | 155 | 171 | buflen += nva[i].valuelen + 1; | 156 | 172 | } | 157 | 173 | } | 158 | 174 |
| 159 | | - buflen += sizeof(nghttp3_nv) * nvlen; | 160 | | - | 161 | 175 | *pnva = nghttp3_mem_malloc(mem, buflen); | 162 | 176 |
| 163 | 177 | if (*pnva == NULL) { | @@ -169,30 +183,28 @@ int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen, | 169 | 183 |
| 170 | 184 | for (i = 0; i < nvlen; ++i) { | 171 | 185 | p->flags = nva[i].flags; | | 186 | + p->namelen = nva[i].namelen; | | 187 | + p->valuelen = nva[i].valuelen; | 172 | 188 |
| 173 | 189 | if (nva[i].flags & NGHTTP3_NV_FLAG_NO_COPY_NAME) { | 174 | 190 | p->name = nva[i].name; | 175 | | - p->namelen = nva[i].namelen; | 176 | 191 | } else { | 177 | 192 | if (nva[i].namelen) { | 178 | 193 | memcpy(data, nva[i].name, nva[i].namelen); | 179 | 194 | nghttp3_downcase(data, nva[i].namelen); | 180 | 195 | } | 181 | 196 | p->name = data; | 182 | | - p->namelen = nva[i].namelen; | 183 | 197 | data[p->namelen] = '\0'; | 184 | 198 | data += nva[i].namelen + 1; | 185 | 199 | } | 186 | 200 |
| 187 | 201 | if (nva[i].flags & NGHTTP3_NV_FLAG_NO_COPY_VALUE) { | 188 | 202 | p->value = nva[i].value; | 189 | | - p->valuelen = nva[i].valuelen; | 190 | 203 | } else { | 191 | 204 | if (nva[i].valuelen) { | 192 | 205 | memcpy(data, nva[i].value, nva[i].valuelen); | 193 | 206 | } | 194 | 207 | p->value = data; | 195 | | - p->valuelen = nva[i].valuelen; | 196 | 208 | data[p->valuelen] = '\0'; | 197 | 209 | data += nva[i].valuelen + 1; | 198 | 210 | } | |
Collapse file Copy file name to clipboardExpand all lines: deps/ngtcp2/nghttp3/lib/nghttp3_frame.h +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -247,6 +247,8 @@ size_t nghttp3_frame_write_origin_len(uint64_t *ppayloadlen, | 247 | 247 | * | 248 | 248 | * NGHTTP3_ERR_NOMEM | 249 | 249 | * Out of memory. | | 250 | + * NGHTTP3_ERR_INVALID_ARGUMENT | | 251 | + * The required memory for |nva| of length |nvlen| is too large. | 250 | 252 | */ | 251 | 253 | int nghttp3_nva_copy(nghttp3_nv **pnva, const nghttp3_nv *nva, size_t nvlen, | 252 | 254 | const nghttp3_mem *mem); | |
|