Skip to content

Add TCP short-write regression test - #1095

Open
anluerz wants to merge 2 commits into
OpenVPN:masterfrom
anluerz:fix/tcp-short-write
Open

Add TCP short-write regression test#1095
anluerz wants to merge 2 commits into
OpenVPN:masterfrom
anluerz:fix/tcp-short-write

Conversation

@anluerz

@anluerz anluerz commented Aug 11, 2026

Copy link
Copy Markdown

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

make check-TESTS TESTS=t_short_write.sh

No root or tun device required the test uses --dev null --ping 1 with the existing sample keys.

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.
@qjoner

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants