forked from osmocom/wireshark
From Jose Pico via bug #5884: Corrected export_object smb segmentation
fault svn path=/trunk/; revision=36979
This commit is contained in:
parent
ec855fcd7e
commit
f97d6d0450
|
@ -64,6 +64,8 @@ enum {
|
|||
EO_NUM_COLUMNS /* must be last */
|
||||
};
|
||||
|
||||
static eo_protocoldata_reset_cb eo_protocoldata_reset = NULL;
|
||||
|
||||
|
||||
static void
|
||||
eo_remember_this_row(GtkTreeModel *model _U_, GtkTreePath *path,
|
||||
|
@ -121,6 +123,9 @@ eo_win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
|||
/* Free the GSList elements */
|
||||
g_slist_free(object_list->entries);
|
||||
g_free(object_list);
|
||||
|
||||
/* Free the private export_object_xxx data */
|
||||
if (eo_protocoldata_reset != NULL) eo_protocoldata_reset();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -350,6 +355,8 @@ eo_reset(void *tapdata)
|
|||
object_list->entries = NULL;
|
||||
object_list->iter = NULL;
|
||||
object_list->row_selected = -1;
|
||||
|
||||
if (eo_protocoldata_reset != NULL) eo_protocoldata_reset();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -386,7 +393,7 @@ eo_draw(void *tapdata)
|
|||
}
|
||||
|
||||
void
|
||||
export_object_window(const gchar *tapname, const gchar *name, tap_packet_cb tap_packet)
|
||||
export_object_window(const gchar *tapname, const gchar *name, tap_packet_cb tap_packet, eo_protocoldata_reset_cb eo_protocoldata_resetfn)
|
||||
{
|
||||
GtkWidget *sw;
|
||||
GtkCellRenderer *renderer;
|
||||
|
@ -398,6 +405,9 @@ export_object_window(const gchar *tapname, const gchar *name, tap_packet_cb tap_
|
|||
export_object_list_t *object_list;
|
||||
gchar *window_title;
|
||||
|
||||
/* Initialize the pointer to the private data clearing function */
|
||||
eo_protocoldata_reset = eo_protocoldata_resetfn;
|
||||
|
||||
/* Initialize our object list structure */
|
||||
object_list = g_malloc0(sizeof(export_object_list_t));
|
||||
|
||||
|
|
|
@ -48,8 +48,17 @@ typedef struct _export_object_entry_t {
|
|||
guint8 *payload_data;
|
||||
} export_object_entry_t;
|
||||
|
||||
/* When a protocol needs intermediate data structures to construct the
|
||||
export objects, then it must specifiy a function that cleans up all
|
||||
those data structures. This function is passed to export_object_window
|
||||
and called when tap reset or windows closes occurs. If no function is needed
|
||||
a NULL value should be passed instead */
|
||||
typedef void (*eo_protocoldata_reset_cb)();
|
||||
|
||||
|
||||
void export_object_window(const gchar *tapname, const gchar *name,
|
||||
tap_packet_cb tap_packet);
|
||||
tap_packet_cb tap_packet,
|
||||
eo_protocoldata_reset_cb eo_protocoldata_resetfn);
|
||||
|
||||
/* Protocol specific */
|
||||
void eo_http_cb(GtkWidget *widget _U_, gpointer data _U_);
|
||||
|
|
|
@ -74,5 +74,5 @@ eo_dicom_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_,
|
|||
void
|
||||
eo_dicom_cb(GtkWidget *widget _U_, gpointer data _U_)
|
||||
{
|
||||
export_object_window("dicom_eo", "DICOM", eo_dicom_packet);
|
||||
export_object_window("dicom_eo", "DICOM", eo_dicom_packet, NULL);
|
||||
}
|
||||
|
|
|
@ -71,5 +71,5 @@ eo_http_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_,
|
|||
void
|
||||
eo_http_cb(GtkWidget *widget _U_, gpointer data _U_)
|
||||
{
|
||||
export_object_window("http_eo", "HTTP", eo_http_packet);
|
||||
export_object_window("http_eo", "HTTP", eo_http_packet, NULL);
|
||||
}
|
||||
|
|
|
@ -79,10 +79,6 @@ typedef struct _active_file {
|
|||
/* This is the GSList that will contain all the files that we are tracking */
|
||||
static GSList *GSL_active_files = NULL;
|
||||
|
||||
/* This is the hash table that will contain the frame numbers of the packets already processed.
|
||||
We want to process each smb packet only once */
|
||||
static GHashTable *visited_packet_hash_table = NULL;
|
||||
|
||||
/* We define a free chunk in a file as an start offset and end offset
|
||||
Consider a free chunk as a "hole" in a file that we are capturing */
|
||||
typedef struct _free_chunk {
|
||||
|
@ -310,25 +306,6 @@ eo_smb_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const
|
|||
|
||||
gchar **aux_string_v;
|
||||
|
||||
|
||||
if (eo_info == NULL) { /* XXX: Can this happen ? */
|
||||
return FALSE; /* State unchanged - no window updates needed */
|
||||
}
|
||||
|
||||
/* Obtain the packet number that originates the analysis */
|
||||
#ifdef SMB_DEBUG
|
||||
printf("\tbtree_visited_packet: Looking for packet %u\n",pinfo->fd-num);
|
||||
#endif
|
||||
|
||||
if (g_hash_table_lookup(visited_packet_hash_table, GUINT_TO_POINTER(pinfo->fd->num)) != NULL) {
|
||||
return FALSE; /* already seen: State unchanged - no window updates needed */
|
||||
}
|
||||
|
||||
/* remember that we've seen this packet */
|
||||
/* XXX: TBD: Is this needed ? */
|
||||
/* Under what circumstances will a packet be encountered twice ? */
|
||||
g_hash_table_insert(visited_packet_hash_table, GUINT_TO_POINTER(pinfo->fd->num), GUINT_TO_POINTER(1));
|
||||
|
||||
/* Is this an eo_smb supported file_type? (right now we only support FILE */
|
||||
is_supported_filetype = (eo_info->fid_type==SMB_FID_TYPE_FILE);
|
||||
|
||||
|
@ -352,7 +329,6 @@ eo_smb_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const
|
|||
active_row=find_incoming_file(GSL_active_files, &incoming_file);
|
||||
|
||||
if (active_row==-1) { /* This is a new-tracked file */
|
||||
|
||||
/* Construct the entry in the list of active files */
|
||||
entry = g_malloc(sizeof(export_object_entry_t));
|
||||
entry->payload_data=NULL;
|
||||
|
@ -439,9 +415,11 @@ eo_smb_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const
|
|||
|
||||
return TRUE; /* State changed - window should be redrawn */
|
||||
}
|
||||
|
||||
/* This is the eo_protocoldata_reset function that is used in the export_object module
|
||||
to cleanup any previous private data of the export object functionality before perform
|
||||
the eo_reset function or when the window closes */
|
||||
void
|
||||
eo_smb_cb(GtkWidget *widget _U_, gpointer data _U_)
|
||||
eo_smb_cleanup()
|
||||
{
|
||||
int i,last;
|
||||
active_file *in_list_file;
|
||||
|
@ -461,14 +439,11 @@ eo_smb_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
g_slist_free(GSL_active_files);
|
||||
GSL_active_files=NULL;
|
||||
}
|
||||
|
||||
/* Initialize the tree */
|
||||
if (visited_packet_hash_table) {
|
||||
g_hash_table_destroy(visited_packet_hash_table);
|
||||
visited_packet_hash_table=NULL;
|
||||
}
|
||||
visited_packet_hash_table=g_hash_table_new(NULL,NULL);
|
||||
|
||||
/* Then call the export_object window */
|
||||
export_object_window("smb_eo", "SMB", eo_smb_packet);
|
||||
}
|
||||
|
||||
void
|
||||
eo_smb_cb(GtkWidget *widget _U_, gpointer data _U_)
|
||||
{
|
||||
/* Call the export_object window */
|
||||
export_object_window("smb_eo", "SMB", eo_smb_packet, eo_smb_cleanup);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue