Skip to content

fix: harden IPv4 address string handling#49

Open
hlolli wants to merge 1 commit into
cleverca22:masterfrom
hlolli:fix/interface-null-termination
Open

fix: harden IPv4 address string handling#49
hlolli wants to merge 1 commit into
cleverca22:masterfrom
hlolli:fix/interface-null-termination

Conversation

@hlolli

@hlolli hlolli commented Mar 18, 2026

Copy link
Copy Markdown

Replace the IPv4 logging paths in the interface code with bounded inet_ntop conversions instead of copying inet_ntoa output with strncpy. The previous code depended on implicit null termination, which is exactly the kind of edge case static analysis tools flag because it can turn a harmless log line into undefined behavior if the buffer contents are ever reused as a C string.

This keeps the behavior the same for normal traffic, but makes the code explicit about buffer sizing and string termination. It also centralizes the conversion in a tiny helper so future address logging in this file can reuse the safer path instead of open-coding it again.

Replace the IPv4 logging paths in the interface code with bounded inet_ntop conversions instead of copying inet_ntoa output with strncpy. The previous code depended on implicit null termination, which is exactly the kind of edge case static analysis tools flag because it can turn a harmless log line into undefined behavior if the buffer contents are ever reused as a C string.

This keeps the behavior the same for normal traffic, but makes the code explicit about buffer sizing and string termination. It also centralizes the conversion in a tiny helper so future address logging in this file can reuse the safer path instead of open-coding it again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant