[PATCH] Tests: tests for proxy_pass with $args changed as a side effect
Maxim Dounin
mdounin at mdounin.ru
Wed Jul 29 04:35:26 UTC 2026
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1785299402 -10800
# Wed Jul 29 07:30:02 2026 +0300
# Node ID 682506de6ffbc1627847d3fa4c475addf604ea79
# Parent 5d1b52ccd445392a64ebb2a9f416f58e9b537945
Tests: tests for proxy_pass with $args changed as a side effect.
diff --git a/grpc_headers.t b/grpc_headers.t
--- a/grpc_headers.t
+++ b/grpc_headers.t
@@ -23,7 +23,7 @@ select STDERR; $| = 1;
select STDOUT; $| = 1;
my $t = Test::Nginx->new()
- ->has(qw/http http_v2 grpc rewrite/)->plan(7)
+ ->has(qw/http http_v2 grpc rewrite/)->plan(8)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
@@ -40,6 +40,10 @@ http {
~(?<capture>.*) $capture;
}
+ map $uri $map_args {
+ ~(?<args>.*) $args;
+ }
+
large_client_header_buffers 2 4m;
ignore_invalid_headers off;
@@ -84,6 +88,11 @@ http {
set $a $a$a$a$a$a$a$a$a$a$a;
set $a $a$a$a$a$a$a$a$a$a$a;
}
+
+ location /map_args {
+ grpc_pass 127.0.0.1:8081;
+ grpc_set_header X-Blah $map_args;
+ }
}
server {
@@ -156,4 +165,19 @@ like(http_get('/long_set?' . ('~' x 210)
}
+TODO: {
+todo_skip 'might coredump', 1
+ unless $t->has_version('1.31.4')
+ or $ENV{TEST_NGINX_UNSAFE};
+local $TODO = 'not yet' unless $t->has_version('1.31.4');
+
+# when $args is changed as a side effect of a variable lookup
+# during grpc_set_header evaluation, buffer allocated might be
+# to small
+
+like(http_get('/map_args/' . ('x' x 512)), qr!/map_args!,
+ '$args changed as side effect');
+
+}
+
###############################################################################
diff --git a/proxy_set_body.t b/proxy_set_body.t
--- a/proxy_set_body.t
+++ b/proxy_set_body.t
@@ -21,7 +21,7 @@ use Test::Nginx;
select STDERR; $| = 1;
select STDOUT; $| = 1;
-my $t = Test::Nginx->new()->has(qw/http proxy rewrite map/)->plan(4)
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite map/)->plan(5)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
@@ -38,6 +38,10 @@ http {
~(?<capture>.*) $capture;
}
+ map $uri $map_args {
+ ~(?<args>.*) $args;
+ }
+
server {
listen 127.0.0.1:8080;
server_name localhost;
@@ -72,6 +76,11 @@ http {
proxy_set_header X-Header "header $capture $map_capture end";
}
+ location /map_args {
+ proxy_pass http://127.0.0.1:8080/body;
+ proxy_set_header X-Header "header $map_args end";
+ }
+
location /body {
add_header X-Body $request_body;
add_header X-Header $http_x_header;
@@ -107,4 +116,19 @@ like(http_get('/map_header'), qr!X-Heade
}
+TODO: {
+todo_skip 'might coredump', 1
+ unless $t->has_version('1.31.4')
+ or $ENV{TEST_NGINX_UNSAFE};
+local $TODO = 'not yet' unless $t->has_version('1.31.4');
+
+# when $args is changed as a side effect of a variable lookup
+# during proxy_set_header or proxy_set_body evaluation, buffer
+# allocated might be to small
+
+like(http_get('/map_args/' . ('x' x 512)), qr!/map_args!,
+ '$args changed as side effect');
+
+}
+
###############################################################################
More information about the nginx-devel
mailing list