<feed xmlns='http://www.w3.org/2005/Atom'>
<title>unit.git, branch wasm</title>
<subtitle>Universal Web Application Server</subtitle>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/'/>
<entry>
<title>[WIP] Wasm: Add a WAMR based language module</title>
<updated>2023-10-10T19:54:39+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-10-10T19:54:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=8f6449f4e0152d9644b807cf2208e3734a0f8b4d'/>
<id>8f6449f4e0152d9644b807cf2208e3734a0f8b4d</id>
<content type='text'>
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Wasm: Re-add a removed 'const' qualifier in nxt_rt_wasmtime.c.</title>
<updated>2023-10-10T19:44:07+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-09-27T20:25:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=01d185cb52af8879aeeab04765eff439feec664c'/>
<id>01d185cb52af8879aeeab04765eff439feec664c</id>
<content type='text'>
This was inadvertently removed in 76086d6d ("Wasm: Allow to set the HTTP
response status.")

Fixes: 76086d6d ("Wasm: Allow to set the HTTP response status.")
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This was inadvertently removed in 76086d6d ("Wasm: Allow to set the HTTP
response status.")

Fixes: 76086d6d ("Wasm: Allow to set the HTTP response status.")
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Update third-party components for the Java module.</title>
<updated>2023-10-10T15:55:44+00:00</updated>
<author>
<name>Sergey A. Osokin</name>
<email>sergey.osokin@nginx.com</email>
</author>
<published>2023-10-10T15:55:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=d1a9069852b78e43aa4e0265cf193743019f41be'/>
<id>d1a9069852b78e43aa4e0265cf193743019f41be</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Tools: unitc YAML mode.</title>
<updated>2023-10-10T14:06:36+00:00</updated>
<author>
<name>Liam Crilly</name>
<email>liam.crilly@nginx.com</email>
</author>
<published>2023-10-10T14:06:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=599b035a544ea27e9fe76cb79f7d672ef114c2d2'/>
<id>599b035a544ea27e9fe76cb79f7d672ef114c2d2</id>
<content type='text'>
Added --format option to manage configuration in other formats.
Initially, YAML is the only supported conversion format.
JSON/YAML conversion is performed with yq(1).

Suggested by: Torstein Krause Johansen &lt;https://github.com/skybert&gt;
Closes: #958 &lt;https://github.com/nginx/unit/issues/958&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Added --format option to manage configuration in other formats.
Initially, YAML is the only supported conversion format.
JSON/YAML conversion is performed with yq(1).

Suggested by: Torstein Krause Johansen &lt;https://github.com/skybert&gt;
Closes: #958 &lt;https://github.com/nginx/unit/issues/958&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Refactored nxt_vsprintf().</title>
<updated>2023-10-10T06:30:02+00:00</updated>
<author>
<name>Zhidao HONG</name>
<email>z.hong@f5.com</email>
</author>
<published>2023-10-10T06:30:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=9c8b9a46a42d47b29453eefc4c5dd325f59e46b4'/>
<id>9c8b9a46a42d47b29453eefc4c5dd325f59e46b4</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Update third-party components for the Java module.</title>
<updated>2023-10-06T16:22:03+00:00</updated>
<author>
<name>Sergey A. Osokin</name>
<email>sergey.osokin@nginx.com</email>
</author>
<published>2023-10-06T16:22:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=c905d0d393378de2fa44d3e21d2bf317a6c3245c'/>
<id>c905d0d393378de2fa44d3e21d2bf317a6c3245c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>HTTP: Fix URL with query string rewrite.</title>
<updated>2023-10-05T12:38:15+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-10-04T23:36:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=30142d2a3c862eef0a32805ee3907535ada32c71'/>
<id>30142d2a3c862eef0a32805ee3907535ada32c71</id>
<content type='text'>
On Github, @rlandgrebe reported an issue when trying to rewrite URLs
that contained query strings.

With the PHP language module we were in fact segfaulting (SIGSEGV) in
libphp

  [93960.462952] unitd[20940]: segfault at 7f307cef6476 ip 00007f2f81a94577 sp 00007fff28a777d0 error 4 in libphp-8.2.so[7f2f818df000+2fd000] likely on CPU 0 (core 0, socket 0)

  #0  0x00007f2abd494577 in php_default_treat_data (arg=1, str=0x0,
      destArray=&lt;optimized out&gt;)
      at /usr/src/debug/php-8.2.10-1.fc38.x86_64/main/php_variables.c:488
  488                     if (c_var &amp;&amp; *c_var) {
  (gdb) p c_var
  $1 = 0x7f2bb8880676 &lt;error: Cannot access memory at address 0x7f2bb8880676&gt;

This was when trying to get the query string which somehow is pointing
off into the woods.

This gdb debug session when doing rewrite basically shows the core of
the issue

  (gdb) x /64bs req-&gt;fields
  ...
  0x7f7eaaaa8090: "GET"
  0x7f7eaaaa8094: "HTTP/1.1"
  0x7f7eaaaa809d: "::1"
  0x7f7eaaaa80a1: "::1"
  0x7f7eaaaa80a5: "8080"
  0x7f7eaaaa80aa: "localhost"
  0x7f7eaaaa80b4: "/test?q=a"
  0x7f7eaaaa80be: "/test"
  ...

  (gdb) p target_pos
  $4 = (void *) 0x7f7eaaaa80b4

  (gdb) p query_pos
  $6 = (void *) 0x7f7eaaaa6af6

  (gdb) p r-&gt;args-&gt;start
  $8 = (u_char *) 0x7f7ea4002b02 "q=a HTTP/1.1\r\nHost: localhost:8080\r\nUser-Agent: curl/8.0.1\r\nAccept: */*\r\n\r\n"
  (gdb) p r-&gt;target.start
  $9 = (u_char *) 0x7f7ea40040c0 "/test?q=a"

That last address, 0x7f7ea40040c0, looks out of wack, it should be
smaller than r-&gt;args-&gt;start.

That results in a calculation in nxt_router_prepare_msg()

  if (r-&gt;args-&gt;start != NULL) {
        query_pos = nxt_pointer_to(target_pos,
                                   r-&gt;args-&gt;start - r-&gt;target.start);

        nxt_unit_sptr_set(&amp;req-&gt;query, query_pos);

  } else {

that goes negative that then is stored in req-&gt;query.offset which is a
uint32_t and so wraps backwards from UINT_MAX to give us an offset of a
little under 4GiB, hence the above invalid memory access.

All this happens due to in nxt_http_rewrite() if we have a URL with a
query string, we create a new memory allocation to store the transformed
URL and query string.

We set r-&gt;target to point to this new allocation, but we also need to
point r-&gt;args-&gt;start to the start of the query string in this new
allocation.

Reported-by: René Landgrebe &lt;https://github.com/rlandgrebe&gt;
Tested-by: René Landgrebe &lt;https://github.com/rlandgrebe&gt;
Tested-by: Liam Crilly &lt;liam.crilly@nginx.com&gt;
Fixes: 14d6d97b ("HTTP: added basic URI rewrite.")
Closes: &lt;https://github.com/nginx/unit/issues/964&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On Github, @rlandgrebe reported an issue when trying to rewrite URLs
that contained query strings.

With the PHP language module we were in fact segfaulting (SIGSEGV) in
libphp

  [93960.462952] unitd[20940]: segfault at 7f307cef6476 ip 00007f2f81a94577 sp 00007fff28a777d0 error 4 in libphp-8.2.so[7f2f818df000+2fd000] likely on CPU 0 (core 0, socket 0)

  #0  0x00007f2abd494577 in php_default_treat_data (arg=1, str=0x0,
      destArray=&lt;optimized out&gt;)
      at /usr/src/debug/php-8.2.10-1.fc38.x86_64/main/php_variables.c:488
  488                     if (c_var &amp;&amp; *c_var) {
  (gdb) p c_var
  $1 = 0x7f2bb8880676 &lt;error: Cannot access memory at address 0x7f2bb8880676&gt;

This was when trying to get the query string which somehow is pointing
off into the woods.

This gdb debug session when doing rewrite basically shows the core of
the issue

  (gdb) x /64bs req-&gt;fields
  ...
  0x7f7eaaaa8090: "GET"
  0x7f7eaaaa8094: "HTTP/1.1"
  0x7f7eaaaa809d: "::1"
  0x7f7eaaaa80a1: "::1"
  0x7f7eaaaa80a5: "8080"
  0x7f7eaaaa80aa: "localhost"
  0x7f7eaaaa80b4: "/test?q=a"
  0x7f7eaaaa80be: "/test"
  ...

  (gdb) p target_pos
  $4 = (void *) 0x7f7eaaaa80b4

  (gdb) p query_pos
  $6 = (void *) 0x7f7eaaaa6af6

  (gdb) p r-&gt;args-&gt;start
  $8 = (u_char *) 0x7f7ea4002b02 "q=a HTTP/1.1\r\nHost: localhost:8080\r\nUser-Agent: curl/8.0.1\r\nAccept: */*\r\n\r\n"
  (gdb) p r-&gt;target.start
  $9 = (u_char *) 0x7f7ea40040c0 "/test?q=a"

That last address, 0x7f7ea40040c0, looks out of wack, it should be
smaller than r-&gt;args-&gt;start.

That results in a calculation in nxt_router_prepare_msg()

  if (r-&gt;args-&gt;start != NULL) {
        query_pos = nxt_pointer_to(target_pos,
                                   r-&gt;args-&gt;start - r-&gt;target.start);

        nxt_unit_sptr_set(&amp;req-&gt;query, query_pos);

  } else {

that goes negative that then is stored in req-&gt;query.offset which is a
uint32_t and so wraps backwards from UINT_MAX to give us an offset of a
little under 4GiB, hence the above invalid memory access.

All this happens due to in nxt_http_rewrite() if we have a URL with a
query string, we create a new memory allocation to store the transformed
URL and query string.

We set r-&gt;target to point to this new allocation, but we also need to
point r-&gt;args-&gt;start to the start of the query string in this new
allocation.

Reported-by: René Landgrebe &lt;https://github.com/rlandgrebe&gt;
Tested-by: René Landgrebe &lt;https://github.com/rlandgrebe&gt;
Tested-by: Liam Crilly &lt;liam.crilly@nginx.com&gt;
Fixes: 14d6d97b ("HTTP: added basic URI rewrite.")
Closes: &lt;https://github.com/nginx/unit/issues/964&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Docker: fix HTML escaping.</title>
<updated>2023-10-04T16:52:06+00:00</updated>
<author>
<name>Liam Crilly</name>
<email>liam.crilly@nginx.com</email>
</author>
<published>2023-10-04T16:52:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=1617f2c04514309a8d19d73103c468af564ef3fd'/>
<id>1617f2c04514309a8d19d73103c468af564ef3fd</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Proxy mentioned in OpenAPI.</title>
<updated>2023-10-04T11:53:03+00:00</updated>
<author>
<name>Andrei Zeliankou</name>
<email>zelenkov@nginx.com</email>
</author>
<published>2023-10-04T11:53:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=37b0f34fb5d6d6525a9d2ae097837324c2697d50'/>
<id>37b0f34fb5d6d6525a9d2ae097837324c2697d50</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Tools: unitc quiet mode fix for macOS.</title>
<updated>2023-10-03T13:57:17+00:00</updated>
<author>
<name>Liam Crilly</name>
<email>liam.crilly@nginx.com</email>
</author>
<published>2023-10-03T13:57:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=9ad207057c620f234f01483bd3a39176945ec202'/>
<id>9ad207057c620f234f01483bd3a39176945ec202</id>
<content type='text'>
head -c 0 does not work on macOS (invalid byte count) but tail(1) is happy
to accept zero bytes, and does not have a performance penalty.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
head -c 0 does not work on macOS (invalid byte count) but tail(1) is happy
to accept zero bytes, and does not have a performance penalty.
</pre>
</div>
</content>
</entry>
</feed>
