aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Wurm <wurm@elastic.co>2017-10-29 01:33:46 +0000
committerMichael Mann <mmann78@netscape.net>2017-10-31 03:28:10 +0000
commit6d8661ceef654b7857caff35f27b71ec364f7f1d (patch)
tree41402a734c357109e8b96deef324732e7b100f6a
parent3a1f958cf87f15cac3b92738d019eb11046fc580 (diff)
Fix segfault in Elasticsearch output
When using the Elasticsearch output but only printing the packet summary with -P a segfault will occur because the empty packet tree is not properly handled in this case. Change-Id: I0c91314ae013785ae6dceabd6af33db4b836d1b2 Reviewed-on: https://code.wireshark.org/review/24153 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/print.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/epan/print.c b/epan/print.c
index 8fa2ce8e76..941184b6ef 100644
--- a/epan/print.c
+++ b/epan/print.c
@@ -380,24 +380,28 @@ write_ek_proto_tree(output_fields_t* fields,
if (print_summary)
write_ek_summary(edt->pi.cinfo, fh);
- fprintf(fh, ", \"layers\" : {");
-
- if (fields == NULL || fields->fields == NULL) {
- /* Write out all fields */
- data.level = 0;
- data.fh = fh;
- data.src_list = edt->pi.data_src;
- data.filter = protocolfilter;
- data.filter_flags = protocolfilter_flags;
- data.print_hex = print_hex;
+ if (edt->tree) {
+ fprintf(fh, ", \"layers\" : {");
+
+ if (fields == NULL || fields->fields == NULL) {
+ /* Write out all fields */
+ data.level = 0;
+ data.fh = fh;
+ data.src_list = edt->pi.data_src;
+ data.filter = protocolfilter;
+ data.filter_flags = protocolfilter_flags;
+ data.print_hex = print_hex;
+
+ proto_tree_write_node_ek(edt->tree, &data);
+ } else {
+ /* Write out specified fields */
+ write_specified_fields(FORMAT_EK, fields, edt, NULL, fh);
+ }
- proto_tree_write_node_ek(edt->tree, &data);
- } else {
- /* Write out specified fields */
- write_specified_fields(FORMAT_EK, fields, edt, NULL, fh);
+ fputs("}", fh);
}
- fputs("}}\n", fh);
+ fputs("}\n", fh);
}
void