netstat: Keep UTF-8 characters in process names#68
Open
stanislav-brabec wants to merge 1 commit into
Open
Conversation
Commit 9beab79 fixed possible ANSI terminal injection. But it also started to sanitize UTF-8 characters in process names making them unreadable. For example (ln -sf /usr/bin/nc /tmp/ncáéí; /tmp/nc* -l 31337 &); netstat -alp was now converted to: nc...... With this change: If LC_CTYPE refers to UTF-8 locale: ncáéí Otherwise: nc?????? Convert special characters to "?" instead of ".". These changes make display names compatible with psmisc ps and iproute2 ss. The escape.c code is based on procps and modified by Stephen Hemminger <stephen@networkplumber.org> for iproute2 ss. Reference: https://lore.kernel.org/all/20250204162429.17902-1-stephen@networkplumber.org/ Due to the licensing reasons, the code is kept in a separate file in lib. But it is not added to the library. Reference: ecki#57
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.
Commit 9beab79 fixed possible ANSI terminal injection. But it also started to sanitize UTF-8 characters in process names making them unreadable.
For example
(ln -sf /usr/bin/nc /tmp/ncáéí; /tmp/nc* -l 31337 &); netstat -alp was now converted to:
nc......
With this change:
If LC_CTYPE refers to UTF-8 locale:
ncáéí
Otherwise:
nc??????
Convert special characters to "?" instead of ".".
These changes make display names compatible with psmisc ps and iproute2 ss.
The escape.c code is based on procps and modified by Stephen Hemminger stephen@networkplumber.org for iproute2 ss.
Reference: https://lore.kernel.org/all/20250204162429.17902-1-stephen@networkplumber.org/
Due to the licensing reasons, the code is kept in a separate file in lib. But it is not added to the library.
Reference: #57