Reject the packet if data is NULL without doing anything else.

Note: We *might* want to do _something_ but that _something_ should be well-defined and consistent across all dissectors.  Previously, some dissectors called proto_tree_add_text() to add some error message text to the tree, while others called DISSECTOR_ASSERT().

svn path=/trunk/; revision=53895
This commit is contained in:
Chris Maynard 2013-12-09 22:23:44 +00:00
parent e3c369eb67
commit 79fa0d0a3f
17 changed files with 109 additions and 159 deletions

View File

@ -87,18 +87,12 @@ dissect_disp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d
const char *disp_op_name;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have operation information from the ROS dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error: can't get operation information from ROS dissector.");
}
/* do we have operation information from the ROS dissector */
if (data == NULL)
return 0;
}
session = (struct SESSION_DATA_STRUCTURE*)data;
session = ((struct SESSION_DATA_STRUCTURE*)data);
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
asn1_ctx.private_data = session;

View File

@ -129,19 +129,13 @@ dissect_dop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da
const char *dop_op_name;
asn1_ctx_t asn1_ctx;
/* do we have operation information from the ROS dissector? */
if (data == NULL)
return 0;
session = (struct SESSION_DATA_STRUCTURE*)data;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have operation information from the ROS dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error: can't get operation information from ROS dissector.");
}
return 0;
}
session = ( (struct SESSION_DATA_STRUCTURE*)data );
item = proto_tree_add_item(parent_tree, proto_dop, tvb, 0, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_dop);

View File

@ -81,19 +81,13 @@ dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da
const char *dsp_op_name;
asn1_ctx_t asn1_ctx;
/* do we have operation information from the ROS dissector? */
if (data == NULL)
return 0;
session = (struct SESSION_DATA_STRUCTURE*)data;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have operation information from the ROS dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error: can't get operation information from ROS dissector.");
}
return 0;
}
session = ( (struct SESSION_DATA_STRUCTURE*)data);
item = proto_tree_add_item(parent_tree, proto_dsp, tvb, 0, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_dsp);

View File

@ -235,20 +235,14 @@ dissect_p1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* dat
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have operation information from the ROS dissector? */
if (data == NULL)
return 0;
session = (struct SESSION_DATA_STRUCTURE*)data;
/* save parent_tree so subdissectors can create new top nodes */
p1_initialize_content_globals (&asn1_ctx, parent_tree, TRUE);
/* do we have operation information from the ROS dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error: can't get operation information from ROS dissector.");
}
return 0;
}
session = ( (struct SESSION_DATA_STRUCTURE*)data );
asn1_ctx.private_data = session;
item = proto_tree_add_item(parent_tree, proto_p1, tvb, 0, -1, ENC_NA);

View File

@ -384,19 +384,14 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have application context from the acse dissector? */
if (data == NULL)
return 0;
asn1_ctx.private_data = data;
/* save parent_tree so subdissectors can create new top nodes */
top_tree=parent_tree;
/* do we have application context from the acse dissector? */
if( !data){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error:can't get application context from ACSE dissector.");
}
return 0;
}
asn1_ctx.private_data = data;
conversation = find_or_create_conversation(pinfo);
/*

View File

@ -207,20 +207,14 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have application context from the acse dissector? */
if (data == NULL)
return 0;
session = (struct SESSION_DATA_STRUCTURE*)data;
/* save parent_tree so subdissectors can create new top nodes */
top_tree=parent_tree;
/* do we have application context from the acse dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error:can't get application context from ACSE dissector.");
}
return 0;
}
session = ( (struct SESSION_DATA_STRUCTURE*)data);
asn1_ctx.private_data = session;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTSE");

View File

@ -1514,18 +1514,12 @@ dissect_disp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d
const char *disp_op_name;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have operation information from the ROS dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error: can't get operation information from ROS dissector.");
}
/* do we have operation information from the ROS dissector */
if (data == NULL)
return 0;
}
session = (struct SESSION_DATA_STRUCTURE*)data;
session = ((struct SESSION_DATA_STRUCTURE*)data);
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
asn1_ctx.private_data = session;
@ -2061,7 +2055,7 @@ void proto_register_disp(void) {
"ShadowErrorData", HFILL }},
/*--- End of included file: packet-disp-hfarr.c ---*/
#line 205 "../../asn1/disp/packet-disp-template.c"
#line 199 "../../asn1/disp/packet-disp-template.c"
};
/* List of subtrees */
@ -2126,7 +2120,7 @@ void proto_register_disp(void) {
&ett_disp_T_signedShadowError,
/*--- End of included file: packet-disp-ettarr.c ---*/
#line 211 "../../asn1/disp/packet-disp-template.c"
#line 205 "../../asn1/disp/packet-disp-template.c"
};
module_t *disp_module;
@ -2165,7 +2159,7 @@ void proto_reg_handoff_disp(void) {
/*--- End of included file: packet-disp-dis-tab.c ---*/
#line 239 "../../asn1/disp/packet-disp-template.c"
#line 233 "../../asn1/disp/packet-disp-template.c"
/* APPLICATION CONTEXT */

View File

@ -2091,19 +2091,13 @@ dissect_dop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da
const char *dop_op_name;
asn1_ctx_t asn1_ctx;
/* do we have operation information from the ROS dissector? */
if (data == NULL)
return 0;
session = (struct SESSION_DATA_STRUCTURE*)data;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have operation information from the ROS dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error: can't get operation information from ROS dissector.");
}
return 0;
}
session = ( (struct SESSION_DATA_STRUCTURE*)data );
item = proto_tree_add_item(parent_tree, proto_dop, tvb, 0, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_dop);
@ -2971,7 +2965,7 @@ void proto_register_dop(void) {
NULL, HFILL }},
/*--- End of included file: packet-dop-hfarr.c ---*/
#line 248 "../../asn1/dop/packet-dop-template.c"
#line 242 "../../asn1/dop/packet-dop-template.c"
};
/* List of subtrees */
@ -3050,7 +3044,7 @@ void proto_register_dop(void) {
&ett_dop_GrantsAndDenials,
/*--- End of included file: packet-dop-ettarr.c ---*/
#line 255 "../../asn1/dop/packet-dop-template.c"
#line 249 "../../asn1/dop/packet-dop-template.c"
};
static ei_register_info ei[] = {
@ -3113,7 +3107,7 @@ void proto_reg_handoff_dop(void) {
/*--- End of included file: packet-dop-dis-tab.c ---*/
#line 295 "../../asn1/dop/packet-dop-template.c"
#line 289 "../../asn1/dop/packet-dop-template.c"
/* APPLICATION CONTEXT */
oid_add_from_string("id-ac-directory-operational-binding-management","2.5.3.3");

View File

@ -1803,19 +1803,13 @@ dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da
const char *dsp_op_name;
asn1_ctx_t asn1_ctx;
/* do we have operation information from the ROS dissector? */
if (data == NULL)
return 0;
session = (struct SESSION_DATA_STRUCTURE*)data;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have operation information from the ROS dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error: can't get operation information from ROS dissector.");
}
return 0;
}
session = ( (struct SESSION_DATA_STRUCTURE*)data);
item = proto_tree_add_item(parent_tree, proto_dsp, tvb, 0, -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_dsp);
@ -2548,7 +2542,7 @@ void proto_register_dsp(void) {
"EXTERNAL", HFILL }},
/*--- End of included file: packet-dsp-hfarr.c ---*/
#line 277 "../../asn1/dsp/packet-dsp-template.c"
#line 271 "../../asn1/dsp/packet-dsp-template.c"
};
/* List of subtrees */
@ -2630,7 +2624,7 @@ void proto_register_dsp(void) {
&ett_dsp_T_basicLevels,
/*--- End of included file: packet-dsp-ettarr.c ---*/
#line 283 "../../asn1/dsp/packet-dsp-template.c"
#line 277 "../../asn1/dsp/packet-dsp-template.c"
};
module_t *dsp_module;
@ -2671,7 +2665,7 @@ void proto_reg_handoff_dsp(void) {
/*--- End of included file: packet-dsp-dis-tab.c ---*/
#line 313 "../../asn1/dsp/packet-dsp-template.c"
#line 307 "../../asn1/dsp/packet-dsp-template.c"
/* APPLICATION CONTEXT */

View File

@ -106,13 +106,18 @@ dissect_hci_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
proto_tree *titem = NULL;
proto_item *pitem = NULL;
gint offset = 0;
usb_conv_info_t *usb_conv_info = (usb_conv_info_t *)data;
usb_conv_info_t *usb_conv_info;
tvbuff_t *next_tvb = NULL;
hci_data_t *hci_data;
gint p2p_dir_save;
guint32 session_id;
fragment_head *reassembled;
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
usb_conv_info = (usb_conv_info_t *)data;
if (tvb_length_remaining(tvb, offset) <= 0)
return 0;
@ -121,8 +126,6 @@ dissect_hci_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI_USB");
DISSECTOR_ASSERT(usb_conv_info);
p2p_dir_save = pinfo->p2p_dir;
pinfo->p2p_dir = usb_conv_info->direction;

View File

@ -8356,20 +8356,14 @@ dissect_p1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* dat
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have operation information from the ROS dissector? */
if (data == NULL)
return 0;
session = (struct SESSION_DATA_STRUCTURE*)data;
/* save parent_tree so subdissectors can create new top nodes */
p1_initialize_content_globals (&asn1_ctx, parent_tree, TRUE);
/* do we have operation information from the ROS dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error: can't get operation information from ROS dissector.");
}
return 0;
}
session = ( (struct SESSION_DATA_STRUCTURE*)data );
asn1_ctx.private_data = session;
item = proto_tree_add_item(parent_tree, proto_p1, tvb, 0, -1, ENC_NA);
@ -10704,7 +10698,7 @@ void proto_register_p1(void) {
NULL, HFILL }},
/*--- End of included file: packet-p1-hfarr.c ---*/
#line 326 "../../asn1/p1/packet-p1-template.c"
#line 320 "../../asn1/p1/packet-p1-template.c"
};
/* List of subtrees */
@ -10903,7 +10897,7 @@ void proto_register_p1(void) {
&ett_p1_SEQUENCE_SIZE_1_ub_recipients_OF_PerRecipientProbeSubmissionFields,
/*--- End of included file: packet-p1-ettarr.c ---*/
#line 339 "../../asn1/p1/packet-p1-template.c"
#line 333 "../../asn1/p1/packet-p1-template.c"
};
static ei_register_info ei[] = {
@ -11106,7 +11100,7 @@ void proto_reg_handoff_p1(void) {
/*--- End of included file: packet-p1-dis-tab.c ---*/
#line 385 "../../asn1/p1/packet-p1-template.c"
#line 379 "../../asn1/p1/packet-p1-template.c"
/* APPLICATION CONTEXT */

View File

@ -1145,8 +1145,12 @@ proto_item_append_text_cwb3_fields(proto_item * item, const pwatm_private_data_t
static int
dissect_control_word(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
{
pwatm_private_data_t* pd = (pwatm_private_data_t *)data;
DISSECTOR_ASSERT(pd != NULL);
pwatm_private_data_t* pd;
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
pd = (pwatm_private_data_t *)data;
/*
* NB: do not touch columns -- keep info from previous dissector
@ -1334,11 +1338,15 @@ dissect_control_word(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, voi
static int
dissect_cell_header(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void * data)
{
pwatm_private_data_t * pd = (pwatm_private_data_t *)data;
pwatm_private_data_t * pd;
gboolean is_enough_data;
int dissect_size;
DISSECTOR_ASSERT (NULL != pd);
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
pd = (pwatm_private_data_t *)data;
pd->vpi = pd->vci = pd->pti = -1;
pd->cwb3.clp = pd->cwb3.m = pd->cwb3.v = pd->cwb3.rsv = pd->cwb3.u = pd->cwb3.e = -1;

View File

@ -1,5 +1,5 @@
/* packet-pn532_hci.c
* Routines for NXP PN532 HCI Protocol
* Routines for NXP PN532 HCI Protocol
*
* http://www.nxp.com/documents/user_manual/141520.pdf
*
@ -76,9 +76,12 @@ dissect_pn532_hci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
guint16 packet_code;
guint16 length;
guint8 checksum;
usb_conv_info_t *usb_conv_info = (usb_conv_info_t *)data;
usb_conv_info_t *usb_conv_info;
DISSECTOR_ASSERT(usb_conv_info);
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
usb_conv_info = (usb_conv_info_t *)data;
length = tvb_length_remaining(tvb, offset);
if (length < 6) return offset;

View File

@ -633,7 +633,7 @@ dissect_pn532(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
tvbuff_t *next_tvb;
gint offset = 0;
command_data_t *command_data = NULL;
usb_conv_info_t *usb_conv_info = (usb_conv_info_t *)data;
usb_conv_info_t *usb_conv_info;
wmem_tree_key_t key[5];
guint32 bus_id;
guint32 device_address;
@ -643,6 +643,11 @@ dissect_pn532(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
guint32 k_endpoint;
guint32 k_frame_number;
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
usb_conv_info = (usb_conv_info_t *)data;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PN532");
item = proto_tree_add_item(tree, proto_pn532, tvb, 0, -1, ENC_NA);
@ -657,8 +662,6 @@ dissect_pn532(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
col_set_str(pinfo->cinfo, COL_INFO, val_to_str_ext_const(cmd, &pn532_commands_ext, "Unknown command"));
DISSECTOR_ASSERT(usb_conv_info);
bus_id = usb_conv_info->bus_id;
device_address = usb_conv_info->device_address;
endpoint = usb_conv_info->endpoint;

View File

@ -1020,19 +1020,14 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have application context from the acse dissector? */
if (data == NULL)
return 0;
asn1_ctx.private_data = data;
/* save parent_tree so subdissectors can create new top nodes */
top_tree=parent_tree;
/* do we have application context from the acse dissector? */
if( !data){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error:can't get application context from ACSE dissector.");
}
return 0;
}
asn1_ctx.private_data = data;
conversation = find_or_create_conversation(pinfo);
/*
@ -1233,7 +1228,7 @@ void proto_register_ros(void) {
"OBJECT_IDENTIFIER", HFILL }},
/*--- End of included file: packet-ros-hfarr.c ---*/
#line 488 "../../asn1/ros/packet-ros-template.c"
#line 483 "../../asn1/ros/packet-ros-template.c"
};
/* List of subtrees */
@ -1254,7 +1249,7 @@ void proto_register_ros(void) {
&ett_ros_Code,
/*--- End of included file: packet-ros-ettarr.c ---*/
#line 495 "../../asn1/ros/packet-ros-template.c"
#line 490 "../../asn1/ros/packet-ros-template.c"
};
static ei_register_info ei[] = {

View File

@ -763,20 +763,14 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
/* do we have application context from the acse dissector? */
if (data == NULL)
return 0;
session = (struct SESSION_DATA_STRUCTURE*)data;
/* save parent_tree so subdissectors can create new top nodes */
top_tree=parent_tree;
/* do we have application context from the acse dissector? */
if( data == NULL ){
if(parent_tree){
proto_tree_add_text(parent_tree, tvb, offset, -1,
"Internal error:can't get application context from ACSE dissector.");
}
return 0;
}
session = ( (struct SESSION_DATA_STRUCTURE*)data);
asn1_ctx.private_data = session;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTSE");
@ -1010,7 +1004,7 @@ void proto_register_rtse(void) {
NULL, HFILL }},
/*--- End of included file: packet-rtse-hfarr.c ---*/
#line 357 "../../asn1/rtse/packet-rtse-template.c"
#line 351 "../../asn1/rtse/packet-rtse-template.c"
};
/* List of subtrees */
@ -1032,7 +1026,7 @@ void proto_register_rtse(void) {
&ett_rtse_CallingSSuserReference,
/*--- End of included file: packet-rtse-ettarr.c ---*/
#line 366 "../../asn1/rtse/packet-rtse-template.c"
#line 360 "../../asn1/rtse/packet-rtse-template.c"
};
static ei_register_info ei[] = {

View File

@ -350,9 +350,12 @@ dissect_ccid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
proto_tree *ccid_tree;
guint8 cmd;
tvbuff_t *next_tvb;
usb_conv_info_t *usb_conv_info = (usb_conv_info_t *)data;
usb_conv_info_t *usb_conv_info;
DISSECTOR_ASSERT(usb_conv_info);
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
usb_conv_info = (usb_conv_info_t *)data;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "USBCCID");
col_set_str(pinfo->cinfo, COL_INFO, "CCID Packet");