(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-wsp.c) |
| |
| 4972 | | | dissect_wsp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, |
| 4973 | | | dissector_handle_t dissector_handle, gboolean is_connectionless) |
| 4974 | | | { |
| 4975 | | | int offset = 0; |
| 4976 | | | |
| 4977 | | | guint8 pdut; |
| 4978 | | | guint count = 0; |
| 4979 | | | guint value = 0; |
| 4980 | | | guint uriLength = 0; |
| 4981 | | | guint uriStart = 0; |
| 4982 | | | guint capabilityLength = 0; |
| 4983 | | | guint capabilityStart = 0; |
| 4984 | | | guint = 0; |
| 4985 | | | guint = 0; |
| 4986 | | | guint = 0; |
| 4987 | | | guint nextOffset = 0; |
| 4988 | | | guint contentTypeStart = 0; |
| 4989 | | | guint contentType = 0; |
| 4990 | | | const char *contentTypeStr; |
| 4991 | | | tvbuff_t *tmp_tvb; |
| 4992 | | | gboolean found_match; |
| 4993 | | | |
| 4994 | | | |
| 4995 | | | proto_item *ti; |
| 4996 | | | proto_item *proto_ti = NULL; |
| 4997 | | | proto_tree *wsp_tree = NULL; |
| 4998 | | | |
| 4999 | | | wsp_info_value_t *stat_info; |
| 5000 | | | stat_info = g_malloc( sizeof(wsp_info_value_t) ); |
| 5001 | | | stat_info->status_code = 0; |
| 5002 | | | |
| 5003 | | | |
| 5004 | | | |
| 5005 | | | |
| 5006 | | | |
| 5007 | | | |
| 5008 | | | if (is_connectionless) |
| 5009 | | | { |
| 5010 | | | offset++; |
| 5011 | | | }; |
| 5012 | | | |
| 5013 | | | |
| 5014 | | | pdut = tvb_get_guint8 (tvb, offset); |
| 5015 | | | |
| 5016 | | | |
| 5017 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 5018 | | | { |
| 5019 | | | col_append_fstr(pinfo->cinfo, COL_INFO, "WSP %s (0x%02x)", |
| 5020 | | | val_to_str (pdut, vals_pdu_type, "Unknown PDU type (0x%02x)"), |
| 5021 | | | pdut); |
| 5022 | | | }; |
| 5023 | | | |
| 5024 | | | |
| 5025 | | | |
| 5026 | | | if (tree) { |
| 5027 | | | proto_ti = proto_tree_add_item(tree, proto_wsp, |
| 5028 | | | tvb, 0, -1, bo_little_endian); |
| 5029 | | | wsp_tree = proto_item_add_subtree(proto_ti, ett_wsp); |
| 5030 | | | proto_item_append_text(proto_ti, ", Method: %s (0x%02x)", |
| 5031 | | | val_to_str (pdut, vals_pdu_type, "Unknown (0x%02x)"), |
| 5032 | | | pdut); |
| 5033 | | | |
| 5034 | | | |
| 5035 | | | |
| 5036 | | | |
| 5037 | | | if (is_connectionless) |
| 5038 | | | { |
| 5039 | | | ti = proto_tree_add_item (wsp_tree, , |
| 5040 | | | tvb, 0, 1, bo_little_endian); |
| 5041 | | | } |
| 5042 | | | ti = proto_tree_add_item( wsp_tree, , |
| 5043 | | | tvb, offset, 1, bo_little_endian); |
| 5044 | | | } |
| 5045 | | | offset++; |
| 5046 | | | |
| 5047 | | | |
| 5048 | | | |
| 5049 | | | if ((pdut >= 0x50) && (pdut <= 0x5F)) |
| 5050 | | | pdut = WSP_PDU_GET; |
| 5051 | | | else if ((pdut >= 0x70) && (pdut <= 0x7F)) |
| 5052 | | | pdut = WSP_PDU_POST; |
| 5053 | | | |
| 5054 | | | switch (pdut) |
| 5055 | | | { |
| 5056 | | | case WSP_PDU_CONNECT: |
| 5057 | | | case WSP_PDU_CONNECTREPLY: |
| 5058 | | | case WSP_PDU_RESUME: |
| 5059 | | | if (tree) { |
| 5060 | | | if (pdut == WSP_PDU_CONNECT) |
| 5061 | | | { |
| 5062 | | | ti = proto_tree_add_item (wsp_tree, hf_wsp_version_major, |
| 5063 | | | tvb, offset, 1, bo_little_endian); |
| 5064 | | | ti = proto_tree_add_item (wsp_tree, hf_wsp_version_minor, |
| 5065 | | | tvb, offset, 1, bo_little_endian); |
| 5066 | | | { |
| 5067 | | | guint8 ver = tvb_get_guint8(tvb, offset); |
| 5068 | | | proto_item_append_text(proto_ti, ", Version: %u.%u", |
| 5069 | | | ver >> 4, ver & 0x0F); |
| 5070 | | | } |
| 5071 | | | offset++; |
| 5072 | | | } else { |
| 5073 | | | count = 0; |
| 5074 | | | value = tvb_get_guintvar (tvb, offset, &count); |
| 5075 | | | ti = proto_tree_add_uint (wsp_tree, |
| 5076 | | | hf_wsp_server_session_id, |
| 5077 | | | tvb, offset, count, value); |
| 5078 | | | proto_item_append_text(proto_ti, ", Session ID: %u", value); |
| 5079 | | | offset += count; |
| 5080 | | | } |
| 5081 | | | capabilityStart = offset; |
| 5082 | | | count = 0; |
| 5083 | | | capabilityLength = tvb_get_guintvar (tvb, offset, &count); |
| 5084 | | | offset += count; |
| 5085 | | | ti = proto_tree_add_uint (wsp_tree, hf_capabilities_length, |
| 5086 | | | tvb, capabilityStart, count, capabilityLength); |
| 5087 | | | |
| 5088 | | | if (pdut != WSP_PDU_RESUME) |
| 5089 | | | { |
| 5090 | | | count = 0; |
| 5091 | | | = tvb_get_guintvar (tvb, offset, &count); |
| 5092 | | | ti = proto_tree_add_uint (wsp_tree, , |
| 5093 | | | tvb, offset, count, ); |
| 5094 | | | offset += count; |
| 5095 | | | capabilityStart = offset; |
| 5096 | | | = capabilityStart + capabilityLength; |
| 5097 | | | } else { |
| 5098 | | | |
| 5099 | | | |
| 5100 | | | capabilityStart = offset; |
| 5101 | | | = capabilityStart + capabilityLength; |
| 5102 | | | = tvb_reported_length_remaining (tvb, |
| 5103 | | | ); |
| 5104 | | | } |
| 5105 | | | if (capabilityLength > 0) |
| 5106 | | | { |
| 5107 | | | tmp_tvb = tvb_new_subset (tvb, offset, |
| 5108 | | | capabilityLength, capabilityLength); |
| 5109 | | | add_capabilities (wsp_tree, tmp_tvb, pdut); |
| 5110 | | | offset += capabilityLength; |
| 5111 | | | } |
| 5112 | | | |
| 5113 | | | if ( > 0) |
| 5114 | | | { |
| 5115 | | | tmp_tvb = tvb_new_subset (tvb, offset, |
| 5116 | | | , ); |
| 5117 | | | (wsp_tree, tmp_tvb, , pinfo); |
| 5118 | | | } |
| 5119 | | | } |
| 5120 | | | |
| 5121 | | | break; |
| 5122 | | | |
| 5123 | | | case WSP_PDU_REDIRECT: |
| 5124 | | | dissect_redirect(tvb, offset, pinfo, wsp_tree, dissector_handle); |
| 5125 | | | break; |
| 5126 | | | |
| 5127 | | | case WSP_PDU_DISCONNECT: |
| 5128 | | | case WSP_PDU_SUSPEND: |
| 5129 | | | if (tree) { |
| 5130 | | | count = 0; |
| 5131 | | | value = tvb_get_guintvar (tvb, offset, &count); |
| 5132 | | | ti = proto_tree_add_uint (wsp_tree, |
| 5133 | | | hf_wsp_server_session_id, |
| 5134 | | | tvb, offset, count, value); |
| 5135 | | | proto_item_append_text(proto_ti, ", Session ID: %u", value); |
| 5136 | | | } |
| 5137 | | | break; |
| 5138 | | | |
| 5139 | | | case WSP_PDU_GET: |
| 5140 | | | case WSP_PDU_OPTIONS: |
| 5141 | | | case WSP_PDU_HEAD: |
| 5142 | | | case WSP_PDU_DELETE: |
| 5143 | | | case WSP_PDU_TRACE: |
| 5144 | | | count = 0; |
| 5145 | | | |
| 5146 | | | value = tvb_get_guintvar (tvb, offset, &count); |
| 5147 | | | nextOffset = offset + count; |
| 5148 | | | add_uri (wsp_tree, pinfo, tvb, offset, nextOffset, proto_ti); |
| 5149 | | | if (tree) { |
| 5150 | | | offset += value + count; |
| 5151 | | | tmp_tvb = tvb_new_subset (tvb, offset, -1, -1); |
| 5152 | | | (wsp_tree, tmp_tvb, , pinfo); |
| 5153 | | | } |
| 5154 | | | break; |
| 5155 | | | |
| 5156 | | | case WSP_PDU_POST: |
| 5157 | | | case WSP_PDU_PUT: |
| 5158 | | | uriStart = offset; |
| 5159 | | | count = 0; |
| 5160 | | | uriLength = tvb_get_guintvar (tvb, offset, &count); |
| 5161 | | | = uriStart+count; |
| 5162 | | | count = 0; |
| 5163 | | | = tvb_get_guintvar (tvb, , &count); |
| 5164 | | | offset = + count; |
| 5165 | | | |
| 5166 | | | add_uri (wsp_tree, pinfo, tvb, uriStart, offset, proto_ti); |
| 5167 | | | offset += uriLength; |
| 5168 | | | |
| 5169 | | | if (tree) |
| 5170 | | | ti = proto_tree_add_uint (wsp_tree, , |
| 5171 | | | tvb, , count, ); |
| 5172 | | | |
| 5173 | | | |
| 5174 | | | |
| 5175 | | | if ( == 0) |
| 5176 | | | break; |
| 5177 | | | |
| 5178 | | | contentTypeStart = offset; |
| 5179 | | | nextOffset = add_content_type (wsp_tree, |
| 5180 | | | tvb, offset, &contentType, &contentTypeStr); |
| 5181 | | | |
| 5182 | | | if (tree) { |
| 5183 | | | |
| 5184 | | | if (contentTypeStr) { |
| 5185 | | | proto_item_append_text(proto_ti, ", Content-Type: %s", |
| 5186 | | | contentTypeStr); |
| 5187 | | | } else { |
| 5188 | | | proto_item_append_text(proto_ti, ", Content-Type: 0x%X", |
| 5189 | | | contentType); |
| 5190 | | | } |
| 5191 | | | |
| 5192 | | | |
| 5193 | | | |
| 5194 | | | |
| 5195 | | | = - (nextOffset - contentTypeStart); |
| 5196 | | | if ( > 0) |
| 5197 | | | { |
| 5198 | | | tmp_tvb = tvb_new_subset (tvb, nextOffset, |
| 5199 | | | , ); |
| 5200 | | | (wsp_tree, tmp_tvb, , pinfo); |
| 5201 | | | } |
| 5202 | | | |
| 5203 | | | offset = nextOffset+; |
| 5204 | | | } |
| 5205 | | | |
| 5206 | | | |
| 5207 | | | if (tvb_reported_length_remaining(tvb, |
| 5208 | | | + count + uriLength + ) > 0) |
| 5209 | | | { |
| 5210 | | | tmp_tvb = tvb_new_subset (tvb, |
| 5211 | | | + count + uriLength + , |
| 5212 | | | -1, -1); |
| 5213 | | | |
| 5214 | | | |
| 5215 | | | |
| 5216 | | | |
| 5217 | | | found_match = FALSE; |
| 5218 | | | if (contentTypeStr) { |
| 5219 | | | |
| 5220 | | | |
| 5221 | | | |
| 5222 | | | found_match = dissector_try_string(media_type_table, |
| 5223 | | | contentTypeStr, tmp_tvb, pinfo, tree); |
| 5224 | | | } |
| 5225 | | | if (! found_match) { |
| 5226 | | | if (! dissector_try_heuristic(heur_subdissector_list, |
| 5227 | | | tmp_tvb, pinfo, tree)) { |
| 5228 | | | guint8* save_private_data = pinfo->private_data; |
| 5229 | | | |
| 5230 | | | pinfo->match_string = contentTypeStr; |
| 5231 | | | pinfo->private_data = NULL; |
| 5232 | | | call_dissector(media_handle, tmp_tvb, pinfo, tree); |
| 5233 | | | pinfo->private_data = save_private_data; |
| 5234 | | | #if 0 |
| 5235 | | | if (tree) |
| 5236 | | | add_post_data (wsp_tree, tmp_tvb, |
| 5237 | | | contentType, contentTypeStr, pinfo); |
| 5238 | | | #endif |
| 5239 | | | } |
| 5240 | | | } |
| 5241 | | | } |
| 5242 | | | break; |
| 5243 | | | |
| 5244 | | | case WSP_PDU_REPLY: |
| 5245 | | | count = 0; |
| 5246 | | | = tvb_get_guintvar (tvb, offset+1, &count); |
| 5247 | | | = offset + count + 1; |
| 5248 | | | { |
| 5249 | | | guint8 reply_status = tvb_get_guint8(tvb, offset); |
| 5250 | | | const char *reply_status_str; |
| 5251 | | | |
| 5252 | | | reply_status_str = val_to_str (reply_status, vals_status, "(Unknown response status)"); |
Ignored Return Value
The return value of val_to_str() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- The return value of val_to_str() is checked 98% of the time in this project. CodeSonar is configured to enforce Ignored Return Value checks for any function whose return value is checked at least 96% of the time, unless the function is used fewer than 20 times. (To modify these thresholds, use configuration file parameters RETURN_CHECKER_SAMPLE_SIZE and RETURN_CHECKER_RATIO. To exempt val_to_str() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 5253 | | | if (tree) { |
Event 2:
Skipping " if". tree evaluates to false.
hide
|
|
| 5254 | | | ti = proto_tree_add_item (wsp_tree, , |
| 5255 | | | tvb, offset, 1, bo_little_endian); |
| 5256 | | | proto_item_append_text(proto_ti, ", Status: %s (0x%02x)", |
| 5257 | | | reply_status_str, reply_status); |
| 5258 | | | } |
| 5259 | | | stat_info->status_code = (gint) reply_status; |
| 5260 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
Event 3:
Skipping " if". check_col(...) evaluates to false.
hide
|
|
| 5261 | | | { |
| 5262 | | | col_append_fstr(pinfo->cinfo, COL_INFO, |
| 5263 | | | ": %s (0x%02x)", |
| 5264 | | | reply_status_str, reply_status); |
| 5265 | | | } |
| 5266 | | | } |
| 5267 | | | nextOffset = offset + 1 + count; |
| 5268 | | | if (tree) |
Event 4:
Skipping " if". tree evaluates to false.
hide
|
|
| 5269 | | | ti = proto_tree_add_uint (wsp_tree, , |
| 5270 | | | tvb, offset + 1, count, ); |
| 5271 | | | |
| 5272 | | | if ( == 0) |
Event 5:
Skipping " if". == 0 evaluates to false.
hide
|
|
| 5273 | | | break; |
| 5274 | | | |
| 5275 | | | contentTypeStart = nextOffset; |
| 5276 | | | nextOffset = add_content_type (wsp_tree, tvb, |
| 5277 | | | nextOffset, &contentType, &contentTypeStr); |
| 5278 | | | |
| 5279 | | | if (tree) { |
Event 6:
Skipping " if". tree evaluates to false.
hide
|
|
| 5280 | | | |
| 5281 | | | if (contentTypeStr) { |
| 5282 | | | proto_item_append_text(proto_ti, ", Content-Type: %s", |
| 5283 | | | contentTypeStr); |
| 5284 | | | } else { |
| 5285 | | | proto_item_append_text(proto_ti, ", Content-Type: 0x%X", |
| 5286 | | | contentType); |
| 5287 | | | } |
| 5288 | | | |
| 5289 | | | |
| 5290 | | | |
| 5291 | | | |
| 5292 | | | = - (nextOffset - contentTypeStart); |
| 5293 | | | if ( > 0) |
| 5294 | | | { |
| 5295 | | | tmp_tvb = tvb_new_subset (tvb, nextOffset, |
| 5296 | | | , ); |
| 5297 | | | (wsp_tree, tmp_tvb, , pinfo); |
| 5298 | | | } |
| 5299 | | | |
| 5300 | | | offset += count++1; |
| 5301 | | | } |
| 5302 | | | |
| 5303 | | | |
| 5304 | | | if (tvb_reported_length_remaining(tvb, + ) |
| 5305 | | | > 0) |
Event 7:
Skipping " if". tvb_reported_length_remaining(...) > 0 evaluates to false.
hide
|
|
| 5306 | | | { |
| 5307 | | | tmp_tvb = tvb_new_subset (tvb, + , |
| 5308 | | | -1, -1); |
| 5309 | | | |
| 5310 | | | |
| 5311 | | | |
| 5312 | | | |
| 5313 | | | found_match = FALSE; |
| 5314 | | | if (contentTypeStr) { |
| 5315 | | | |
| 5316 | | | |
| 5317 | | | |
| 5318 | | | found_match = dissector_try_string(media_type_table, |
| 5319 | | | contentTypeStr, tmp_tvb, pinfo, tree); |
| 5320 | | | } |
| 5321 | | | if (! found_match) { |
| 5322 | | | if (! dissector_try_heuristic(heur_subdissector_list, |
| 5323 | | | tmp_tvb, pinfo, tree)) { |
| 5324 | | | guint8* save_private_data = pinfo->private_data; |
| 5325 | | | |
| 5326 | | | pinfo->match_string = contentTypeStr; |
| 5327 | | | pinfo->private_data = NULL; |
| 5328 | | | call_dissector(media_handle, tmp_tvb, pinfo, tree); |
| 5329 | | | pinfo->private_data = save_private_data; |
| 5330 | | | #if 0 |
| 5331 | | | if (tree) / * Only display if needed * / |
| 5332 | | | ti = proto_tree_add_item (wsp_tree, |
| 5333 | | | hf_wsp_reply_data, |
| 5334 | | | tmp_tvb, 0, -1, bo_little_endian); |
| 5335 | | | #endif |
| 5336 | | | } |
| 5337 | | | } |
| 5338 | | | } |
| 5339 | | | break; |
| 5340 | | | |
| 5341 | | | case WSP_PDU_PUSH: |
| 5342 | | | case WSP_PDU_CONFIRMEDPUSH: |
| 5343 | | | count = 0; |
| 5344 | | | = tvb_get_guintvar (tvb, offset, &count); |
| 5345 | | | = offset + count; |
| 5346 | | | |
| 5347 | | | if (tree) |
| 5348 | | | ti = proto_tree_add_uint (wsp_tree, , |
| 5349 | | | tvb, offset, count, ); |
| 5350 | | | |
| 5351 | | | if ( == 0) |
| 5352 | | | break; |
| 5353 | | | |
| 5354 | | | offset += count; |
| 5355 | | | contentTypeStart = offset; |
| 5356 | | | nextOffset = add_content_type (wsp_tree, |
| 5357 | | | tvb, offset, &contentType, &contentTypeStr); |
| 5358 | | | |
| 5359 | | | if (tree) { |
| 5360 | | | |
| 5361 | | | if (contentTypeStr) { |
| 5362 | | | proto_item_append_text(proto_ti, ", Content-Type: %s", |
| 5363 | | | contentTypeStr); |
| 5364 | | | } else { |
| 5365 | | | proto_item_append_text(proto_ti, ", Content-Type: 0x%X", |
| 5366 | | | contentType); |
| 5367 | | | } |
| 5368 | | | |
| 5369 | | | |
| 5370 | | | |
| 5371 | | | |
| 5372 | | | = -(nextOffset-contentTypeStart); |
| 5373 | | | if ( > 0) |
| 5374 | | | { |
| 5375 | | | tmp_tvb = tvb_new_subset (tvb, nextOffset, |
| 5376 | | | , ); |
| 5377 | | | (wsp_tree, tmp_tvb, , pinfo); |
| 5378 | | | } |
| 5379 | | | |
| 5380 | | | offset += ; |
| 5381 | | | } |
| 5382 | | | |
| 5383 | | | |
| 5384 | | | if (tvb_reported_length_remaining(tvb, + ) |
| 5385 | | | > 0) |
| 5386 | | | { |
| 5387 | | | tmp_tvb = tvb_new_subset (tvb, + , |
| 5388 | | | -1, -1); |
| 5389 | | | |
| 5390 | | | |
| 5391 | | | |
| 5392 | | | |
| 5393 | | | found_match = FALSE; |
| 5394 | | | if (contentTypeStr) { |
| 5395 | | | |
| 5396 | | | |
| 5397 | | | |
| 5398 | | | |
| 5399 | | | |
| 5400 | | | |
| 5401 | | | |
| 5402 | | | |
| 5403 | | | found_match = dissector_try_string(media_type_table, |
| 5404 | | | contentTypeStr, tmp_tvb, pinfo, tree); |
| 5405 | | | } |
| 5406 | | | if (! found_match) { |
| 5407 | | | if (! dissector_try_heuristic(heur_subdissector_list, |
| 5408 | | | tmp_tvb, pinfo, tree)) { |
| 5409 | | | guint8* save_private_data = pinfo->private_data; |
| 5410 | | | |
| 5411 | | | pinfo->match_string = contentTypeStr; |
| 5412 | | | pinfo->private_data = NULL; |
| 5413 | | | call_dissector(media_handle, tmp_tvb, pinfo, tree); |
| 5414 | | | pinfo->private_data = save_private_data; |
| 5415 | | | #if 0 |
| 5416 | | | if (tree) |
| 5417 | | | ti = proto_tree_add_item (wsp_tree, |
| 5418 | | | hf_wsp_push_data, |
| 5419 | | | tmp_tvb, 0, -1, bo_little_endian); |
| 5420 | | | #endif |
| 5421 | | | } |
| 5422 | | | } |
| 5423 | | | } |
| 5424 | | | break; |
| 5425 | | | |
| 5426 | | | } |
| 5427 | | | stat_info->pdut = pdut; |
| 5428 | | | tap_queue_packet (wsp_tap, pinfo, stat_info); |
| 5429 | | | } |
| |