fix #1190 support to display packet content as UTF-8#1382
fix #1190 support to display packet content as UTF-8#1382lotabout wants to merge 1 commit intothe-tcpdump-group:masterfrom
Conversation
992ccb1 to
6ee3b82
Compare
2ecc6b2 to
354fa81
Compare
|
I tried this on Windows using MSVC and clang-cl. But there is no print-ascii.c(118,11): error: call to undeclared function 'wcwidth'; ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]
118 | int w = wcwidth(wc);
| ^ |
|
How did it build in Appveyor then? |
Since |
9c0622f to
a5fa5a2
Compare
|
@gvanem Could you please help me give it another try on Windows? I’ve added Markus Kuhn’s implementation as a replacement on Windows. |
6629672 to
a13a471
Compare
|
@gvanem Please help to try again with latest code, it turns out that locale should be set correctly for (left: tcpdump, right: cat. Compiled on Windows 11 with VS 2022, Shell: PowerShell with
|
a448b15 to
d991fd2
Compare
|
tcpdump CI is failing because of my recent changes in libpcap. Please wait until this is fixed. |
@infrastation Got it, Thanks~ |
a5fa5a2 to
a13a471
Compare
|
Work very well now! |
a13a471 to
870f465
Compare
870f465 to
b5f77ca
Compare
|
@fxlb Hi! Sorry for the ping (I saw you're very active here). This is my first PR to this project — is there anything else I should do to help get it merged, apart from passing the CI checks? |
|
Why is nobody besides me and @lotabout interested in merging this? |
|
|
||
|
|
||
| /* | ||
| * The blow is_utf8_printable is taken from ngrep |
There was a problem hiding this comment.
Presumably that should be "The below is_utf8_printable is taken from ngrep".
| } | ||
|
|
||
| /* Check if the wide character is printable */ | ||
| #if defined(_WIN32) || defined(_WIN64) |
There was a problem hiding this comment.
Are there any compilers for Windows that define _WIN64, but don't define _WIN32, on "modern" Windows? ("modern" here means "not 16-bit Windows".)
| utf8_len = ndo->ndo_utf8 ? is_utf8_printable(cp, length, NULL) : 0; | ||
|
|
||
| if (utf8_len > 0) { | ||
| /* Valid printable UTF-8 character */ |
There was a problem hiding this comment.
What if utf8_len is greater than length - i.e., you have a partial UTF-8 character?
|
The title of the pull request and commit message should probably be just "Add support to display packet content as UTF-8", with "Fix #1190" in the body of the commit message. |
|
|
I agree that for this new feature it is more important to implement it safely than quickly. In particular, it should be impossible to weaponise it as is sometimes done using ANSI escape codes, see CVE-2025-46394 for one example. So this requires a bit more attention before it is declared safe and ready. |




This PR adds a new --utf8 option to enable UTF-8 character support.
When UTF-8 support is enabled, tcpdump will detect and display UTF-8 characters in the payload as-is when using the
-Aoption.Note that in
-Xmode, if a multi-byte character spans across two lines, it will appear on the first line, and a spaces will be padded on the next line.Tests
-Aand-x, ensuring their MD5 checksums remain identical without --utf8.utf8.pcap.zip