Fix: in the Web add-on, packets may be incorrectly released in case of errors - #395
Fix: in the Web add-on, packets may be incorrectly released in case of errors#395Yves57 wants to merge 5 commits into
Conversation
|
Thank you for this contribution, @Yves57. Please excuse the delay in getting back to you as I was on vacation. Before we can accept this PR, you need to sign the Eclipse Contributor Agreement (ECA). The purpose of the ECA is to provide a written record that you have agreed to provide your code and documentation contributions under the licenses used by the Eclipse ThreadX project. It also makes it clear that you are promising that what you are contributing to Eclipse is code you wrote, and you have the necessary rights to contribute it to our projects. And finally, it documents a commitment from you that your open source contributions will be permanently on the public record. Signing the ECA requires an Eclipse Foundation account if you do not already have one. You can create one for free at https://accounts.eclipse.org. Be sure to use the same email address when you register for the account that you intend to use on Git commit records. Also, please add your GitHub ID to your Eclipse account. This enables synchronisation between Eclipse-owned infrastructure and GitHub. Here is the link to sign the ECA: |
|
@fdesbiens It should be good for the agreement. |
|
Hi @Yves57 |
The two Content-Length underflow branches in _nx_web_http_server_put_process were the only error exits in that function that released nothing at all. Every neighbouring exit releases the request packet when the request is chunked. A chunked request cannot currently reach either branch, because length is initialised from nx_packet_length so the subtraction cannot wrap. Relying on that invariant for correctness is fragile, so release the packet the same way the surrounding paths do. Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
The underflow detection in _nx_web_http_server_put_process had no coverage. A raw TCP client now sends a PUT whose Content-Length is smaller than the body it carries, and the test checks that the server answers 400 and that its packet pool is fully restored afterwards. Registered in the web regression CMake list and in netx_https_testcontrol. Verified against default_build_coverage, no_tls_build_coverage and digest_authenticate_build: 54/54 pass in each, no new warnings under -Werror. Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thanks Yves — good catch, and the diagnosis was exactly right. I have pushed two follow-up commits to your branch and retargeted the PR from 1. Release the request packet on the chunked path
After your change, the two underflow exits became the only error exits in That is harmless today, because a chunked request cannot actually reach either underflow branch: 2. A regression test for the underflow path
New file: The underflow detection had no coverage at all — One thing worth being explicit about, since it is easy to assume otherwise: this test does not fail on the unpatched code. What the removed calls did depended entirely on the contents of an uninitialized stack slot, which is not something a test can pin down. I verified this by reintroducing the two calls and re-running — the test still passed. So please read it as coverage that locks in the correct behaviour of a previously untested branch, not as a reproducer for the defect you fixed. The pool-availability assertion is there to catch leaks and double releases on this path in future. VerificationBuilt and run with CMake and Ninja across all three web configurations — One process noteContributions to this project should be based on Thanks again for the fix and for the clear problem statement in the PR description. It made this an easy one to confirm. If everything looks right to you, then I will merge this to dev right away. This will ship with our Q3 2026 release in September. |
|
@fdesbiens The additional modifications seem correct to me. |
data_packet_ptris released while it is never initialized at this point.