examples: fix local socket address lengths#3601
Open
Old-Ding wants to merge 1 commit into
Open
Conversation
36c57ec to
bf8cc5c
Compare
bf8cc5c to
50ac971
Compare
Contributor
|
@Old-Ding please rebase your chang to the last master which fix the ci error. |
50ac971 to
b016d61
Compare
The configured path size already includes its NUL terminator. Adding another byte made the maximum address length exceed sockaddr_un, while ustream could write at sun_path[UNIX_PATH_MAX]. Use the existing bounded copy length directly as the path portion of the socket address and rely on strlcpy for termination. Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
b016d61 to
4ed4f10
Compare
xiaoxiang781216
approved these changes
Jul 13, 2026
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.
Summary
sizeof(CONFIG_EXAMPLES_*_ADDR)path size, which already includes the terminating NUL.sizeof(sa_family_t)tobind(),connect(), andsendto()without adding a second NUL byte.strlcpy()already terminates the bounded destination.Why
The examples treated
sizeof(CONFIG_EXAMPLES_*_ADDR)as the pathname size, including its NUL terminator, and then added another byte to the socket address length. At the maximum pathname size, the supplied length could exceedstruct sockaddr_unby one byte.The stream examples also wrote
sun_path[addrlen] = '\0'after clampingaddrlentoUNIX_PATH_MAX, which could write one byte pastsun_path.Testing
sizeof(struct sockaddr_un).git diff origin/master...HEAD --check4ed4f10edirectly onto master62b7e955.CI notes
Linux (sim-02)failure was in unrelatedsim/login:CONFIG_BOARD_ETC_ROMFS_PASSWD_PASSWORD is not set.1d15c81f(ci: supply sim/login ROMFS passwd credential in build jobs), which directly fixes that base CI configuration.Linux (sim-02)and all other runnable matrix jobs pass on current head4ed4f10e; macOS was skipped by workflow selection.