Add TCP short-write regression test - #1095
Open
anluerz wants to merge 2 commits into
Open
Conversation
Adds an LD_PRELOAD shim (short_write_shim.c) that intercepts send() and injects a short write on P_DATA_V1/V2 packets, and a test script (t_short_write.sh) that confirms stream corruption results. Currently FAILs — the bug is present. Linux-only; exits 77 (SKIP) elsewhere. Wires the shim and script into tests/Makefile.am under a TARGET_LINUX guard; adds that conditional to configure.ac.
A short write on a TCP socket left the stream corrupt. Track partial writes and retry until the packet drains.
This comment was marked as spam.
This comment was marked as spam.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a self-contained regression test that demonstrates the bug reported in issue #1094: link_socket_write_tcp_posix() calls send() once with no retry, and a short write permanently corrupts the TCP framing.
The test currently FAILs (bug present). It is intended to be paired with a follow-up fix, after which it should PASS.
What's included
tests/short_write_shim.c: An LD_PRELOAD shim that intercepts send() and injects a short write on P_DATA_V1/P_DATA_V2 packets (opcodes 6 and 9), while letting TLS handshake traffic pass through unmodified. This ensures the session is fully established before the data channel is corrupted.tests/t_short_write.sh: A test script that starts a loopback TCP server, runs a client with the shim preloaded, and checks whether the truncation warning appears in the log. Exit 1 (FAIL) = bug present; exit 0 (PASS) = bug fixed; exit 77 (SKIP) = prerequisites missing (e.g. macOS, missing binary).tests/Makefile.am: shim and script wired into the test suite under a TARGET_LINUX guard.configure.ac: adds the TARGET_LINUX conditional (mainly because I have no other platforms available)How to run
No root or tun device required the test uses
--dev null --ping 1with the existing sample keys.