DCOM: always NUL-terminate dissect_dcom_BSTR results
[metze/wireshark/wip.git] / sharkd.c
index fcc6160f1d20e642fd994aa0bf676289fef88d91..bc35ced1f4f5f5ae26d6d92c05e1b46096e23d03 100644 (file)
--- a/sharkd.c
+++ b/sharkd.c
@@ -49,7 +49,6 @@
 #include "ui/filter_files.h"
 #include "ui/tap_export_pdu.h"
 #include "ui/failure_message.h"
-#include "epan/register.h"
 #include <epan/epan_dissect.h>
 #include <epan/tap.h>
 #include <epan/uat-int.h>
@@ -168,8 +167,7 @@ main(int argc, char *argv[])
      "-G" flag, as the "-G" flag dumps information registered by the
      dissectors, and we must do it before we read the preferences, in
      case any dissectors register preferences. */
-  if (!epan_init(register_all_protocols, register_all_protocol_handoffs, NULL,
-                 NULL)) {
+  if (!epan_init(NULL, NULL, TRUE)) {
     ret = EPAN_INIT_FAIL;
     goto clean_exit;
   }
@@ -413,10 +411,6 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
 
   /* The open succeeded.  Fill in the information for this file. */
 
-  /* Create new epan session for dissection. */
-  epan_free(cf->epan);
-  cf->epan = sharkd_epan_new(cf);
-
   cf->provider.wth = wth;
   cf->f_datalen = 0; /* not used, but set it anyway */
 
@@ -442,6 +436,10 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
   cf->provider.prev_dis = NULL;
   cf->provider.prev_cap = NULL;
 
+  /* Create new epan session for dissection. */
+  epan_free(cf->epan);
+  cf->epan = sharkd_epan_new(cf);
+
   cf->state = FILE_READ_IN_PROGRESS;
 
   wtap_set_cb_new_ipv4(cf->provider.wth, add_ipv4_name);
@@ -546,6 +544,7 @@ sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, guint32 prev_dis
   ws_buffer_init(&buf, 1500);
 
   if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info)) {
+    wtap_rec_cleanup(&rec);
     ws_buffer_free(&buf);
     return -1; /* error reading the record */
   }
@@ -606,6 +605,7 @@ sharkd_dissect_columns(frame_data *fdata, guint32 frame_ref_num, guint32 prev_di
 
   if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info)) {
     col_fill_in_error(cinfo, fdata, FALSE, FALSE /* fill_fd_columns */);
+    wtap_rec_cleanup(&rec);
     ws_buffer_free(&buf);
     return -1; /* error reading the record */
   }
@@ -728,6 +728,12 @@ sharkd_filter(const char *dftext, guint8 **result)
     return -1;
   }
 
+  /* if dfilter_compile() success, but (dfcode == NULL) all frames are matching */
+  if (dfcode == NULL) {
+    *result = NULL;
+    return 0;
+  }
+
   frames_count = cfile.count;
 
   wtap_rec_init(&rec);