Skip to content

examples: Fix network echo receive terminators#3597

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Old-Ding:codex/net-echo-buffer-terminator
Jul 9, 2026
Merged

examples: Fix network echo receive terminators#3597
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Old-Ding:codex/net-echo-buffer-terminator

Conversation

@Old-Ding

@Old-Ding Old-Ding commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

The netloop and poll TCP echo examples receive up to IOBUFFER_SIZE bytes and then append a NUL terminator before logging the received data. A full-size receive can therefore write one byte past the input buffer.

Reserve one extra byte for the buffers that are terminated after recv(), while keeping the receive limit and echo length capped at IOBUFFER_SIZE.

Validation

  • git diff --check origin/master..HEAD
  • git show --check --stat --oneline HEAD
  • git ls-files --eol examples/netloop/lo_main.c examples/netloop/lo_listener.c examples/poll/host.c examples/poll/net_listener.c examples/poll/net_reader.c

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Old-Ding, please update your Singature to valid email in case we need to contact you :-)

@Old-Ding Old-Ding force-pushed the codex/net-echo-buffer-terminator branch from f0f8563 to 1f91bdd Compare July 8, 2026 03:01
The netloop and poll TCP echo examples receive up to IOBUFFER_SIZE bytes and then append a NUL terminator before logging the data. A full-size receive can therefore write one byte past the input buffer.

Reserve one extra byte in the buffers that are terminated after recv(). Keep the receive limit and echo length capped at IOBUFFER_SIZE so the data path is unchanged.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
@Old-Ding Old-Ding force-pushed the codex/net-echo-buffer-terminator branch from 1f91bdd to c0b2176 Compare July 8, 2026 13:50
@xiaoxiang781216 xiaoxiang781216 merged commit 50ffee7 into apache:master Jul 9, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants