aboutsummaryrefslogtreecommitdiffstats
path: root/sharkd_session.c
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 /sharkd_session.c
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 'sharkd_session.c')
-rw-r--r--sharkd_session.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sharkd_session.c b/sharkd_session.c
index c9aa258407..7faef005f6 100644
--- a/sharkd_session.c
+++ b/sharkd_session.c
@@ -1087,7 +1087,17 @@ sharkd_session_process_load(const char *buf, const jsmntok_t *tokens, int count)
ENDTRY;
if (err == 0)
+ {
sharkd_json_simple_ok(rpcid);
+ }
+ else
+ {
+ sharkd_json_result_prologue(rpcid);
+ sharkd_json_value_string("status", wtap_strerror(err));
+ sharkd_json_value_anyf("err", "%d", err);
+ sharkd_json_result_epilogue();
+ }
+
}
/**