diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-05-16 18:32:35 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-05-16 18:32:35 +0000 |
commit | 2b4f0dff0082d8daad2db1067b5f2c49243eb9ab (patch) | |
tree | 512734f9153ef522f72b4fe4b16d934b06e7b152 /epan/dissectors/packet-smb.c | |
parent | 21a1231e31ee1a4562d2bbd3bc500e5655b3c0a5 (diff) |
Fix some comments.
Get rid of null-pointer tests for t2i in the "not null" branch of an
earlier test whether it's null, as those tests are redundant.
Use a switch statement to check the subcommand for Trans2.
If t2i->info_level is -1, it means we don't know the info level, for
whatever reason (e.g., the request was cut short by the snapshot length
before the info level). Report it as such.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@37183 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-smb.c')
-rw-r--r-- | epan/dissectors/packet-smb.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index 9dd2bb94e9..3a64a5d30e 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -11932,7 +11932,7 @@ int dissect_qfi_SMB_FILE_POSITION_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc) { - /* file id */ + /* file position */ CHECK_BYTE_COUNT_SUBR(8); proto_tree_add_item(tree, hf_smb_position, tvb, offset, 8, TRUE); COUNT_BYTES_SUBR(8); @@ -12008,7 +12008,7 @@ int dissect_qfi_SMB_FILE_ENDOFFILE_INFO(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, guint16 *bcp, gboolean *trunc) { - /* end of file */ + /* offset of end of file */ CHECK_BYTE_COUNT_SUBR(8); proto_tree_add_item(tree, hf_smb_end_of_file, tvb, offset, 8, TRUE); COUNT_BYTES_SUBR(8); @@ -15899,37 +15899,50 @@ dissect_transaction_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * col_append_str(pinfo->cinfo, COL_INFO, "<unknown>"); } else { proto_tree_add_uint(tree, hf_smb_trans2_subcmd, tvb, 0, 0, t2i->subcmd); - /* FIND_FIRST2 */ - if(t2i && t2i->subcmd==0x0001){ - item=proto_tree_add_uint(tree, hf_smb_ff2_information_level, tvb, 0, 0, t2i->info_level); + switch (t2i->subcmd) { + + case 0x0001: /* FIND_FIRST2 */ + if (t2i->info_level == -1) + item=proto_tree_add_text(tree, tvb, 0, 0, "Level of Information: <UNKNOWN> since information level wasn't found in request packet"); + else + item=proto_tree_add_uint(tree, hf_smb_ff2_information_level, tvb, 0, 0, t2i->info_level); PROTO_ITEM_SET_GENERATED(item); if(t2i->name){ item=proto_tree_add_string(tree, hf_smb_search_pattern, tvb, 0, 0, t2i->name); PROTO_ITEM_SET_GENERATED(item); } - } + break; - /* QUERY_PATH_INFORMATION */ - if(t2i && t2i->subcmd==0x0005){ - item=proto_tree_add_uint(tree, hf_smb_qpi_loi, tvb, 0, 0, t2i->info_level); + case 0x0005: /* QUERY_PATH_INFORMATION */ + if (t2i->info_level == -1) + item=proto_tree_add_text(tree, tvb, 0, 0, "Level of Information: <UNKNOWN> since information level wasn't found in request packet"); + else + item=proto_tree_add_uint(tree, hf_smb_qpi_loi, tvb, 0, 0, t2i->info_level); PROTO_ITEM_SET_GENERATED(item); if(t2i->name){ item=proto_tree_add_string(tree, hf_smb_file_name, tvb, 0, 0, t2i->name); PROTO_ITEM_SET_GENERATED(item); } - } - /* QUERY_FILE_INFORMATION */ - if(t2i && t2i->subcmd==0x0007){ - item=proto_tree_add_uint(tree, hf_smb_qpi_loi, tvb, 0, 0, t2i->info_level); + break; + + case 0x0007: /* QUERY_FILE_INFORMATION */ + if (t2i->info_level == -1) + item=proto_tree_add_text(tree, tvb, 0, 0, "Level of Information: <UNKNOWN> since information level wasn't found in request packet"); + else + item=proto_tree_add_uint(tree, hf_smb_qpi_loi, tvb, 0, 0, t2i->info_level); PROTO_ITEM_SET_GENERATED(item); - } - /* QUERY_FS_INFORMATION */ - if(t2i && t2i->subcmd==0x0003){ - item=proto_tree_add_uint(tree, hf_smb_qfsi_information_level, tvb, 0, 0, si->info_level); + break; + + case 0x0003: /* QUERY_FS_INFORMATION */ + if (t2i->info_level == -1) + item=proto_tree_add_text(tree, tvb, 0, 0, "Level of Information: <UNKNOWN> since information level wasn't found in request packet"); + else + item=proto_tree_add_uint(tree, hf_smb_qfsi_information_level, tvb, 0, 0, si->info_level); PROTO_ITEM_SET_GENERATED(item); + break; } - if (t2i && check_col(pinfo->cinfo, COL_INFO)) { + if (check_col(pinfo->cinfo, COL_INFO)) { col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str_ext(t2i->subcmd, &trans2_cmd_vals_ext, |