Skip to content

examples: Fix network echo receive terminators#3597

Open
Old-Ding wants to merge 1 commit into
apache:masterfrom
Old-Ding:codex/net-echo-buffer-terminator
Open

examples: Fix network echo receive terminators#3597
Old-Ding wants to merge 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

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 <35417409+Old-Ding@users.noreply.github.com>

@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 :-)

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.

3 participants