From f97d1c419347e9b9e23a83ee4b2a18b749cffe57 Mon Sep 17 00:00:00 2001 From: Hakase Date: Tue, 23 May 2023 11:42:22 +0900 Subject: [PATCH] Latest update - 9113 (merged default - quic branch) --- docs/text/LICENSE | 2 +- misc/GNUmakefile | 2 ++ src/core/ngx_regex.c | 6 +++--- src/event/quic/ngx_event_quic.c | 4 ++-- src/event/quic/ngx_event_quic_ack.c | 1 + src/event/quic/ngx_event_quic_openssl_compat.h | 3 ++- src/event/quic/ngx_event_quic_streams.c | 18 +++++++++++++----- src/event/quic/ngx_event_quic_udp.c | 2 +- src/http/ngx_http_variables.c | 6 ++++-- 9 files changed, 29 insertions(+), 15 deletions(-) diff --git a/docs/text/LICENSE b/docs/text/LICENSE index fdedcb7..2792c44 100644 --- a/docs/text/LICENSE +++ b/docs/text/LICENSE @@ -1,6 +1,6 @@ /* * Copyright (C) 2002-2021 Igor Sysoev - * Copyright (C) 2011-2022 Nginx, Inc. + * Copyright (C) 2011-2023 Nginx, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/misc/GNUmakefile b/misc/GNUmakefile index a5c4a19..bd7ce5d 100644 --- a/misc/GNUmakefile +++ b/misc/GNUmakefile @@ -75,6 +75,8 @@ win32: --with-http_slice_module \ --with-mail \ --with-stream \ + --with-stream_realip_module \ + --with-stream_ssl_preread_module \ --with-openssl=$(OBJS)/lib/$(OPENSSL) \ --with-openssl-opt="no-asm no-tests -D_WIN32_WINNT=0x0501" \ --with-http_ssl_module \ diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c index bebf3b6..91381f4 100644 --- a/src/core/ngx_regex.c +++ b/src/core/ngx_regex.c @@ -732,14 +732,14 @@ ngx_regex_create_conf(ngx_cycle_t *cycle) return NULL; } - cln->handler = ngx_regex_cleanup; - cln->data = rcf; - rcf->studies = ngx_list_create(cycle->pool, 8, sizeof(ngx_regex_elt_t)); if (rcf->studies == NULL) { return NULL; } + cln->handler = ngx_regex_cleanup; + cln->data = rcf; + ngx_regex_studies = rcf->studies; return rcf; diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c index b4033bc..b559c48 100644 --- a/src/event/quic/ngx_event_quic.c +++ b/src/event/quic/ngx_event_quic.c @@ -844,7 +844,7 @@ ngx_quic_handle_packet(ngx_connection_t *c, ngx_quic_conf_t *conf, "quic stateless reset packet detected"); qc->draining = 1; - ngx_quic_close_connection(c, NGX_OK); + ngx_post_event(&qc->close, &ngx_posted_events); return NGX_OK; } @@ -1390,7 +1390,7 @@ ngx_quic_handle_frames(ngx_connection_t *c, ngx_quic_header_t *pkt) if (do_close) { qc->draining = 1; - ngx_quic_close_connection(c, NGX_OK); + ngx_post_event(&qc->close, &ngx_posted_events); } if (pkt->path != qc->path && nonprobing) { diff --git a/src/event/quic/ngx_event_quic_ack.c b/src/event/quic/ngx_event_quic_ack.c index 062b065..21ee888 100644 --- a/src/event/quic/ngx_event_quic_ack.c +++ b/src/event/quic/ngx_event_quic_ack.c @@ -806,6 +806,7 @@ void ngx_quic_lost_handler(ngx_event_t *ev) if (ngx_quic_detect_lost(c, NULL) != NGX_OK) { ngx_quic_close_connection(c, NGX_ERROR); + return; } ngx_quic_connstate_dbg(c); diff --git a/src/event/quic/ngx_event_quic_openssl_compat.h b/src/event/quic/ngx_event_quic_openssl_compat.h index d980051..b04f6e0 100644 --- a/src/event/quic/ngx_event_quic_openssl_compat.h +++ b/src/event/quic/ngx_event_quic_openssl_compat.h @@ -7,7 +7,8 @@ #ifndef _NGX_EVENT_QUIC_OPENSSL_COMPAT_H_INCLUDED_ #define _NGX_EVENT_QUIC_OPENSSL_COMPAT_H_INCLUDED_ -#ifdef TLSEXT_TYPE_quic_transport_parameters +#if defined SSL_R_MISSING_QUIC_TRANSPORT_PARAMETERS_EXTENSION \ + || defined LIBRESSL_VERSION_NUMBER #undef NGX_QUIC_OPENSSL_COMPAT #else diff --git a/src/event/quic/ngx_event_quic_streams.c b/src/event/quic/ngx_event_quic_streams.c index 6664dfd..b4b0eda 100644 --- a/src/event/quic/ngx_event_quic_streams.c +++ b/src/event/quic/ngx_event_quic_streams.c @@ -1084,7 +1084,8 @@ ngx_quic_stream_cleanup_handler(void *data) { ngx_connection_t *c = data; - ngx_quic_stream_t *qs; + ngx_quic_stream_t *qs; + ngx_quic_connection_t *qc; qs = c->quic; @@ -1092,16 +1093,23 @@ ngx_quic_stream_cleanup_handler(void *data) "quic stream id:0x%xL cleanup", qs->id); if (ngx_quic_shutdown_stream(c, NGX_RDWR_SHUTDOWN) != NGX_OK) { - ngx_quic_close_connection(c, NGX_ERROR); - return; + goto failed; } qs->connection = NULL; if (ngx_quic_close_stream(qs) != NGX_OK) { - ngx_quic_close_connection(c, NGX_ERROR); - return; + goto failed; } + + return; + +failed: + + qc = ngx_quic_get_connection(qs->parent); + qc->error = NGX_QUIC_ERR_INTERNAL_ERROR; + + ngx_post_event(&qc->close, &ngx_posted_events); } diff --git a/src/event/quic/ngx_event_quic_udp.c b/src/event/quic/ngx_event_quic_udp.c index 71754a4..15b54bc 100644 --- a/src/event/quic/ngx_event_quic_udp.c +++ b/src/event/quic/ngx_event_quic_udp.c @@ -183,7 +183,7 @@ ngx_quic_recvmsg(ngx_event_t *ev) qsock = ngx_quic_get_socket(c); - ngx_memcpy(&qsock->sockaddr.sockaddr, sockaddr, socklen); + ngx_memcpy(&qsock->sockaddr, sockaddr, socklen); qsock->socklen = socklen; c->udp->buffer = &buf; diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 16ffda3..4f0bd0e 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -828,7 +828,7 @@ ngx_http_variable_headers_internal(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data, u_char sep) { size_t len; - u_char *p; + u_char *p, *end; ngx_table_elt_t *h, *th; h = *(ngx_table_elt_t **) ((char *) r + data); @@ -870,6 +870,8 @@ ngx_http_variable_headers_internal(ngx_http_request_t *r, v->len = len; v->data = p; + end = p + len; + for (th = h; th; th = th->next) { if (th->hash == 0) { @@ -878,7 +880,7 @@ ngx_http_variable_headers_internal(ngx_http_request_t *r, p = ngx_copy(p, th->value.data, th->value.len); - if (th->next == NULL) { + if (p == end) { break; }