Skip to content

examples: xmlrpc: bound header value copy#3602

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Old-Ding:codex/xmlrpc-header-value-bound
Jul 9, 2026
Merged

examples: xmlrpc: bound header value copy#3602
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Old-Ding:codex/xmlrpc-header-value-bound

Conversation

@Old-Ding

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

Copy link
Copy Markdown
Contributor

Summary

  • make xmlrpc_getheader() treat its size argument as the destination capacity
  • reserve one byte for the terminating NUL while copying the header value
  • pass sizeof(value) from xmlrpc_handler() instead of the HTTP request buffer size

Why

xmlrpc_handler() stores Content-Length in value, which is sized as CONFIG_XMLRPC_STRINGSIZE + 1. The previous call passed CONFIG_EXAMPLES_XMLRPC_BUFFERSIZE to xmlrpc_getheader(); with the defaults, that permits copying up to 1024 bytes into a 65 byte destination.

The helper also wrote the terminator after allowing i == size, so the capacity contract should reserve space for the NUL byte.

Testing

  • git diff --check HEAD~1..HEAD
  • git show --stat --check --format=fuller HEAD
  • Not run: local NuttX apps build, because this Windows workstation does not have gcc, clang, or cc installed.

@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, looks good, just please update git commit signature to valid email address :-)

@Old-Ding Old-Ding force-pushed the codex/xmlrpc-header-value-bound branch from 21e989e to a77586f Compare July 8, 2026 01:41
xmlrpc_handler() stores HTTP header values in a CONFIG_XMLRPC_STRINGSIZE + 1 byte buffer, but it passed CONFIG_EXAMPLES_XMLRPC_BUFFERSIZE to xmlrpc_getheader(). With the defaults, that allows a 1024 byte copy into a 65 byte destination.

Make xmlrpc_getheader() treat size as the destination capacity, reserve one byte for the terminator, and pass sizeof(value) from the caller.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
@Old-Ding Old-Ding force-pushed the codex/xmlrpc-header-value-bound branch from a77586f to fdbf9fd Compare July 8, 2026 13:50
@xiaoxiang781216 xiaoxiang781216 merged commit 54905cd 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.

5 participants