Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Could not decode PDML data: ... "illegal character code" #133

Open
3 tasks
clort81 opened this issue Dec 2, 2021 · 3 comments
Open
3 tasks

Warning: Could not decode PDML data: ... "illegal character code" #133

clort81 opened this issue Dec 2, 2021 · 3 comments

Comments

@clort81
Copy link

clort81 commented Dec 2, 2021

Prerequisites

Please verify these before submitting an issue.

  • I am running the latest versions of Termshark and Wireshark.

Package: termshark
Version: 2.2.0-2

Yes

  • I searched issues and this has not yet been filed

Yes

Problem

Running sudo termshark -i [interface] works then displays warning box:
"Could not decode PDML data: XML syntax error on line 78925: illegal character code U+0006."

Current Behavior

Running sudo termshark -i [interface] works then displays warning box:
"Could not decode PDML data: XML syntax error on line 78925: illegal character code U+0006."

Expected Behavior

No warning popup box.

Screenshots as applicable

Steps to Reproduce

Run termshark -i eth0

Context

Please provide the complete output of these commands:

termshark -v
termshark 2.2.0

Please also provide any relevant information about your environment (OS, VM, pi,...)

Devuan ceres, aarch64

@clort81
Copy link
Author

clort81 commented Dec 2, 2021

the error appears in pcap/loader.go

                Loop:
                        for {
                                tok, err := d.Token()
                                if err != nil {
                                        if !issuedKill && unexpectedPdmlError(err) {
                                                err = fmt.Errorf("Could not read PDML data: %v", err)
                                                issuedKill = true
                                                pdmlCancelFn()                                                          
                                                HandleError(PdmlCode, app, err, cb)
                                        }
                                        if err == io.EOF {
                                                readAllRequiredPdml = true
                                        }
                                        break

not knowing go, i haven't been able to disable it yet.

@gcla
Copy link
Owner

gcla commented Dec 3, 2021

Hi @clort81 - yes you're right, that's the source of the message that termshark emits. The problem seems to come from invalid XML generated by tshark in some circumstances. I saw it most recently working with telnet. If you download this pcap, you can see the invalid XML by running this command:

https://drive.google.com/file/d/1B3NJv8oOARlY7aztkVNA8oB4SYGFfas3/view?usp=sharing

$ tshark -r zork.pcap -T pdml | xmllint --noout -
-:1485: parser error : invalid character in attribute value
ield name="telnet.data" showname="Data: �\030\001" size="3" pos="40" show="
                                                                               ^
-:1485: parser error : attributes construct error
ield name="telnet.data" showname="Data: �\030\001" size="3" pos="40" show="�
                                                                               ^
...

These characters fail isInCharacterRange() from the Go stdlib's xml.go. I'm not certain about this diagnosis yet though...

I could suppress the message but the problem really is that the XML parsing breaks at this point. While I look more closely, here's a crummy workaround:

  • create the following file called e.g. /usr/local/bin/tshark-hack
#!/usr/bin/env bash

if [[ " $* " =~ " pdml " ]]; then
    exec tshark "$@" | tr -cd '\11\12\15\40-\176'
else
    exec tshark "$@"
fi
  • sudo chmod +x /usr/local/bin/tshark-hack

  • edit ~/.config/termshark/termshark.toml

[main]
  tshark = "/usr/local/bin/tshark-hack"

Let me know if that doesn't work :-)

gcla added a commit that referenced this issue Jul 10, 2022
If this value is not set explicitly, a false value means that an error
from a termshark-initiated tshark process will result in an error dialog
in the termshark UI. I am seeing this more and more as I test with
various pcaps - it always comes from tshark serializing characters into
XML text that are invalid, according to the XML spec (val <= 31 and val
not in {tab, CR, LF}). Here is a merge request against Wireshark to try
to solve this problem at the source:
https://gitlab.com/wireshark/wireshark/-/merge_requests/7398

To see the problem, try this:

$ wget https://storage.googleapis.com/gcla3/xmlbug.pcapng
$ tshark -r xmlbug.pcapng -T pdml | xmllint --noout - || echo bad xml

Even if this Wireshark request is merged, it will presumably be a long
time before all termshark-used tsharks are updated. So I think the more
user-friendly option is to suppress these errors to avoid popups about
which the user can do very little anyway.

Here's a hack you can use if you want to see errors, in general, but are
not interested in this specific XML error:

#133 (comment)

Workaround:

- create the following file called e.g. /usr/local/bin/tshark-hack

if [[ " $* " =~ " pdml " ]]; then
    exec tshark "$@" | tr -cd '\11\12\15\40-\176'
else
    exec tshark "$@"
fi

- run:

$ sudo chmod +x /usr/local/bin/tshark-hack

- edit ~/.config/termshark/termshark.toml

[main]
  tshark = "/usr/local/bin/tshark-hack"
@gcla
Copy link
Owner

gcla commented Jul 15, 2022

Here's a Wireshark merge-request to fix this at the source:

https://gitlab.com/wireshark/wireshark/-/merge_requests/7398

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

No branches or pull requests

2 participants