Mercurial > hg > nginx
comparison src/event/quic/ngx_event_quic_transport.c @ 9072:def8e398d7c5 quic
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Previously, since 3550b00d9dc8, the token was allocated on stack, to get
rid of pool usage. Now the token is allocated by ngx_quic_copy_buffer()
in QUIC buffers, also used for STREAM, CRYPTO and ACK frames.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Tue, 31 Jan 2023 15:26:33 +0400 |
parents | a26897674420 |
children | efd91f6afa8d |
comparison
equal
deleted
inserted
replaced
9071:3c98fa8fef6f | 9072:def8e398d7c5 |
---|---|
107 ngx_quic_stop_sending_frame_t *ss); | 107 ngx_quic_stop_sending_frame_t *ss); |
108 static size_t ngx_quic_create_crypto(u_char *p, | 108 static size_t ngx_quic_create_crypto(u_char *p, |
109 ngx_quic_crypto_frame_t *crypto, ngx_chain_t *data); | 109 ngx_quic_crypto_frame_t *crypto, ngx_chain_t *data); |
110 static size_t ngx_quic_create_hs_done(u_char *p); | 110 static size_t ngx_quic_create_hs_done(u_char *p); |
111 static size_t ngx_quic_create_new_token(u_char *p, | 111 static size_t ngx_quic_create_new_token(u_char *p, |
112 ngx_quic_new_token_frame_t *token); | 112 ngx_quic_new_token_frame_t *token, ngx_chain_t *data); |
113 static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf, | 113 static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf, |
114 ngx_chain_t *data); | 114 ngx_chain_t *data); |
115 static size_t ngx_quic_create_max_streams(u_char *p, | 115 static size_t ngx_quic_create_max_streams(u_char *p, |
116 ngx_quic_max_streams_frame_t *ms); | 116 ngx_quic_max_streams_frame_t *ms); |
117 static size_t ngx_quic_create_max_stream_data(u_char *p, | 117 static size_t ngx_quic_create_max_stream_data(u_char *p, |
1299 | 1299 |
1300 case NGX_QUIC_FT_HANDSHAKE_DONE: | 1300 case NGX_QUIC_FT_HANDSHAKE_DONE: |
1301 return ngx_quic_create_hs_done(p); | 1301 return ngx_quic_create_hs_done(p); |
1302 | 1302 |
1303 case NGX_QUIC_FT_NEW_TOKEN: | 1303 case NGX_QUIC_FT_NEW_TOKEN: |
1304 return ngx_quic_create_new_token(p, &f->u.token); | 1304 return ngx_quic_create_new_token(p, &f->u.token, f->data); |
1305 | 1305 |
1306 case NGX_QUIC_FT_STREAM: | 1306 case NGX_QUIC_FT_STREAM: |
1307 return ngx_quic_create_stream(p, &f->u.stream, f->data); | 1307 return ngx_quic_create_stream(p, &f->u.stream, f->data); |
1308 | 1308 |
1309 case NGX_QUIC_FT_CONNECTION_CLOSE: | 1309 case NGX_QUIC_FT_CONNECTION_CLOSE: |
1489 return p - start; | 1489 return p - start; |
1490 } | 1490 } |
1491 | 1491 |
1492 | 1492 |
1493 static size_t | 1493 static size_t |
1494 ngx_quic_create_new_token(u_char *p, ngx_quic_new_token_frame_t *token) | 1494 ngx_quic_create_new_token(u_char *p, ngx_quic_new_token_frame_t *token, |
1495 { | 1495 ngx_chain_t *data) |
1496 size_t len; | 1496 { |
1497 u_char *start; | 1497 size_t len; |
1498 u_char *start; | |
1499 ngx_buf_t *b; | |
1498 | 1500 |
1499 if (p == NULL) { | 1501 if (p == NULL) { |
1500 len = ngx_quic_varint_len(NGX_QUIC_FT_NEW_TOKEN); | 1502 len = ngx_quic_varint_len(NGX_QUIC_FT_NEW_TOKEN); |
1501 len += ngx_quic_varint_len(token->length); | 1503 len += ngx_quic_varint_len(token->length); |
1502 len += token->length; | 1504 len += token->length; |
1506 | 1508 |
1507 start = p; | 1509 start = p; |
1508 | 1510 |
1509 ngx_quic_build_int(&p, NGX_QUIC_FT_NEW_TOKEN); | 1511 ngx_quic_build_int(&p, NGX_QUIC_FT_NEW_TOKEN); |
1510 ngx_quic_build_int(&p, token->length); | 1512 ngx_quic_build_int(&p, token->length); |
1511 p = ngx_cpymem(p, token->data, token->length); | 1513 |
1514 while (data) { | |
1515 b = data->buf; | |
1516 p = ngx_cpymem(p, b->pos, b->last - b->pos); | |
1517 data = data->next; | |
1518 } | |
1512 | 1519 |
1513 return p - start; | 1520 return p - start; |
1514 } | 1521 } |
1515 | 1522 |
1516 | 1523 |