Skip to content

netstat: Keep UTF-8 characters in process names - #68

Merged
ecki merged 2 commits into
ecki:masterfrom
stanislav-brabec:master
Jul 18, 2026
Merged

netstat: Keep UTF-8 characters in process names#68
ecki merged 2 commits into
ecki:masterfrom
stanislav-brabec:master

Conversation

@stanislav-brabec

Copy link
Copy Markdown
Contributor

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

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
@ecki
ecki merged commit 7ee79c9 into ecki:master Jul 18, 2026
4 checks passed
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.

2 participants