fix strncpy truncation; enable FORTIFY_SOURCE=3#1218
Open
xq9mend wants to merge 2 commits into
Open
Conversation
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
xq9mend
force-pushed
the
fix/gcc-fortify-source-3
branch
from
July 4, 2026 09:45
68eeb55 to
76d9d7d
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
zmq message buffers are length-prefixed byte blobs — the reader uses zmq_msg_size(), not null termination. strncpy stops at the first null byte in the serialized boost archive, corrupting messages that contain embedded nulls. memcpy copies exactly s.size() bytes unconditionally, which is the semantically correct call for raw byte blobs. Also silences the FORTIFY_SOURCE=3 provable-truncation diagnostic on this call site. Signed-off-by: xq9mend <xq9mend@users.noreply.github.com>
xq9mend
force-pushed
the
fix/gcc-fortify-source-3
branch
from
July 5, 2026 12:24
2389b01 to
336c0b8
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: xq9mend <xq9mend@users.noreply.github.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Why I did it
zmq_msg_init_size()allocates a byte buffer sized exactlys.size()— no room for a null terminator. The ZMQ message reader (zmsg_to_map) constructs astd::stringusingzmq_msg_size(), so null termination is irrelevant.strncpyis the wrong primitive here;memcpyis semantically correct for raw byte blobs and eliminates the FORTIFY_SOURCE=3 provable-truncation diagnostic.Also upgrade FORTIFY_SOURCE to level 3 in
debian/rulesso all future builds use the stronger compile-time check. dpkg sets =2 by default; the-Uflag clears it before setting =3.How I did it
common/events_common.h: replacestrncpywithmemcpyinmap_to_zmsg()debian/rules: addDEB_CPPFLAGS_MAINT_APPEND = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3How to verify it
Build passes cleanly with
dpkg-buildpackage. No compiler warnings or errors related to FORTIFY_SOURCE.