# HG changeset patch # User Maxim Dounin <mdou...@mdounin.ru> # Date 1746113698 -10800 # Thu May 01 18:34:58 2025 +0300 # Node ID 6d64b685bc7fbee88e31ce54a151de0deeaabdde # Parent b325ee44215f5e1ff102d7dbfc15ffe5b285bb9d Compatibility with -Wunterminated-string-initialization in GCC 15.
Builds with recently released GCC 15 currently fail due to -Wunterminated-string-initialization (introduced in -Wextra), which warns about attempts to initialize a character array with a string literal if the trailing NUL character doesn't fit (perfectly valid in C, but might be unintentional). Fix is to use arrays for initialization instead of string literals, or switch to using character arrays of unknown size where appropriate. diff --git a/src/event/quic/ngx_event_quic_protection.c b/src/event/quic/ngx_event_quic_protection.c --- a/src/event/quic/ngx_event_quic_protection.c +++ b/src/event/quic/ngx_event_quic_protection.c @@ -122,9 +122,10 @@ ngx_quic_keys_set_initial_secret(ngx_qui ngx_quic_secret_t *client, *server; ngx_quic_ciphers_t ciphers; - static const uint8_t salt[20] = - "\x38\x76\x2c\xf7\xf5\x59\x34\xb3\x4d\x17" - "\x9a\xe6\xa4\xc8\x0c\xad\xcc\xbb\x7f\x0a"; + static const uint8_t salt[20] = { + 0x38, 0x76, 0x2c, 0xf7, 0xf5, 0x59, 0x34, 0xb3, 0x4d, 0x17, + 0x9a, 0xe6, 0xa4, 0xc8, 0x0c, 0xad, 0xcc, 0xbb, 0x7f, 0x0a + }; client = &keys->secrets[ssl_encryption_initial].client; server = &keys->secrets[ssl_encryption_initial].server; @@ -936,10 +937,14 @@ ngx_quic_create_retry_packet(ngx_quic_he ngx_quic_ciphers_t ciphers; /* 5.8. Retry Packet Integrity */ - static u_char key_data[16] = - "\xbe\x0c\x69\x0b\x9f\x66\x57\x5a\x1d\x76\x6b\x54\xe3\x68\xc8\x4e"; - static u_char nonce[NGX_QUIC_IV_LEN] = - "\x46\x15\x99\xd3\x5d\x63\x2b\xf2\x23\x98\x25\xbb"; + static u_char key_data[16] = { + 0xbe, 0x0c, 0x69, 0x0b, 0x9f, 0x66, 0x57, 0x5a, 0x1d, 0x76, + 0x6b, 0x54, 0xe3, 0x68, 0xc8, 0x4e + }; + static u_char nonce[NGX_QUIC_IV_LEN] = { + 0x46, 0x15, 0x99, 0xd3, 0x5d, 0x63, 0x2b, 0xf2, 0x23, 0x98, + 0x25, 0xbb + }; static ngx_str_t in = ngx_string(""); ad.data = res->data; diff --git a/src/http/v2/ngx_http_v2_filter_module.c b/src/http/v2/ngx_http_v2_filter_module.c --- a/src/http/v2/ngx_http_v2_filter_module.c +++ b/src/http/v2/ngx_http_v2_filter_module.c @@ -116,7 +116,7 @@ ngx_http_v2_header_filter(ngx_http_reque u_char addr[NGX_SOCKADDR_STRLEN]; #if (NGX_HTTP_GZIP) - static const u_char accept_encoding[12] = + static const u_char accept_encoding[] = "\x8b\x84\x84\x2d\x69\x5b\x05\x44\x3c\x86\xaa\x6f"; #endif @@ -341,7 +341,7 @@ ngx_http_v2_header_filter(ngx_http_reque #if (NGX_HTTP_GZIP) if (r->gzip_vary) { if (clcf->gzip_vary) { - len += 1 + sizeof(accept_encoding); + len += 1 + sizeof(accept_encoding) - 1; } else { r->gzip_vary = 0; @@ -568,7 +568,7 @@ ngx_http_v2_header_filter(ngx_http_reque "http2 output header: \"vary: Accept-Encoding\""); *pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_VARY_INDEX); - pos = ngx_cpymem(pos, accept_encoding, sizeof(accept_encoding)); + pos = ngx_cpymem(pos, accept_encoding, sizeof(accept_encoding) - 1); } #endif