aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorZach Chadwick <zachad@qacafe.com>2023-02-28 10:04:37 -0500
committerJohn Thacker <johnthacker@gmail.com>2023-03-01 11:33:02 +0000
commitd98f6b16ef2974454a881d8ed8ba3e0964c39e91 (patch)
tree702743f3ab9589645293dc87b6487eff25a63864 /test
parent1236c07a03dd394cc4aeb4dd687522c80a40e79e (diff)
Sharkd: Return error message on load if err!=0
Fixes a bug when the return value from load_cap_file() is nonzero. No response is currently returned causing the client to hang. A non-zero error code can happen for a variety of reasons, one of which is when the PCAP is truncated. An error message from cfile_read_failure_message() is displayed on the console, but no data was returned to the RPC client. This adds a call to wtap_strerrror() to look up a human consumable error message for the specific error code returned during wtap_read(). Adds new self-test to suite_sharkd.py
Diffstat (limited to 'test')
-rw-r--r--test/captures/trunc.pcapbin0 -> 995 bytes
-rw-r--r--test/suite_sharkd.py9
2 files changed, 9 insertions, 0 deletions
diff --git a/test/captures/trunc.pcap b/test/captures/trunc.pcap
new file mode 100644
index 0000000000..8dd75ed5ac
--- /dev/null
+++ b/test/captures/trunc.pcap
Binary files differ
diff --git a/test/suite_sharkd.py b/test/suite_sharkd.py
index 4f3a8d4fcb..93b263dd50 100644
--- a/test/suite_sharkd.py
+++ b/test/suite_sharkd.py
@@ -70,6 +70,15 @@ class case_sharkd(subprocesstest.SubprocessTestCase):
{"jsonrpc":"2.0","id":1,"error":{"code":-2001,"message":"Unable to open the file"}},
))
+ def test_sharkd_req_load_truncated_pcap(self, check_sharkd_session, capture_file):
+ check_sharkd_session((
+ {"jsonrpc":"2.0", "id":1, "method":"load",
+ "params":{"file": capture_file('trunc.pcap')}
+ },
+ ), (
+ {"jsonrpc":"2.0","id":1,"result":{"status":"Less data was read than was expected","err":-12}},
+ ))
+
def test_sharkd_req_status_no_pcap(self, check_sharkd_session):
check_sharkd_session((
{"jsonrpc":"2.0", "id":1, "method":"status"},