Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at packet-wsp.c:5252

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

dissect_wsp_common

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-wsp.c)expand/collapse
Show more  
 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 headersLength = 0;
 4985          guint headerLength = 0;
 4986          guint headerStart = 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  /* Set up structures we will need to add the protocol subtree and manage it */
 4995          proto_item *ti;
 4996          proto_item *proto_ti = NULL; /* for the proto entry */
 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  /* This field shows up as the "Info" column in the display; you should make 
 5004     it, if possible, summarize what's in the packet, so that a user looking 
 5005     at the list of packets can tell what type of packet it is. */
 5006   
 5007          /* Connection-less mode has a TID first */
 5008          if (is_connectionless)
 5009          {
 5010                  offset++; /* Skip the 1-byte Transaction ID */
 5011          };
 5012   
 5013          /* Find the PDU type */
 5014          pdut = tvb_get_guint8 (tvb, offset);
 5015   
 5016          /* Develop the string to put in the Info column */
 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          /* In the interest of speed, if "tree" is NULL, don't do any work not
 5025           * necessary to generate protocol tree items. */
 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                  /* Add common items: only TID and PDU Type */
 5035   
 5036                  /* If this is connectionless, then the TID Field is always first */
 5037                  if (is_connectionless)
 5038                  {
 5039                          ti = proto_tree_add_item (wsp_tree, hf_wsp_header_tid,
 5040                                          tvb, 0, 1, bo_little_endian);
 5041                  }
 5042                  ti = proto_tree_add_item( wsp_tree, hf_wsp_header_pdu_type,
 5043                                  tvb, offset, 1, bo_little_endian);
 5044          }
 5045          offset++;
 5046   
 5047          /* Map extended methods to the main method now the Column info has been 
 5048           * written; this way we can dissect the extended method PDUs. */
 5049          if ((pdut >= 0x50) && (pdut <= 0x5F)) /* Extended GET --> GET */
 5050                  pdut = WSP_PDU_GET;
 5051          else if ((pdut >= 0x70) && (pdut <= 0x7F)) /* Extended POST --> POST */
 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;      /* Initialise count */
 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;      /* Initialise count */
 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;      /* Initialise count */
 5091                                          headerLength = tvb_get_guintvar (tvb, offset, &count);
 5092                                          ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,
 5093                                                          tvb, offset, count, headerLength);
 5094                                          offset += count;
 5095                                          capabilityStart = offset;
 5096                                          headerStart = capabilityStart + capabilityLength;
 5097                                  } else {
 5098                                                  /* Resume computes the headerlength
 5099                                                   * by remaining bytes */
 5100                                          capabilityStart = offset;
 5101                                          headerStart = capabilityStart + capabilityLength;
 5102                                          headerLength = tvb_reported_length_remaining (tvb,
 5103                                                          headerStart);
 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 (headerLength > 0)
 5114                                  {
 5115                                          tmp_tvb = tvb_new_subset (tvb, offset,
 5116                                                          headerLength, headerLength);
 5117                                          add_headers (wsp_tree, tmp_tvb, hf_wsp_headers_section, pinfo);
 5118                                  }
 5119                          } /* if (tree) */
 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;      /* Initialise count */
 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;      /* Initialise count */
 5145                          /* Length of URI and size of URILen field */
 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; /* VERIFY */
 5151                                  tmp_tvb = tvb_new_subset (tvb, offset, -1, -1);
 5152                                  add_headers (wsp_tree, tmp_tvb, hf_wsp_headers_section, pinfo);
 5153                          }
 5154                          break;
 5155   
 5156                  case WSP_PDU_POST:
 5157                  case WSP_PDU_PUT:
 5158                          uriStart = offset;
 5159                          count = 0;      /* Initialise count */
 5160                          uriLength = tvb_get_guintvar (tvb, offset, &count);
 5161                          headerStart = uriStart+count;
 5162                          count = 0;      /* Initialise count */
 5163                          headersLength = tvb_get_guintvar (tvb, headerStart, &count);
 5164                          offset = headerStart + 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, hf_wsp_header_length,
 5171                                                  tvb, headerStart, count, headersLength);
 5172   
 5173                          /* Stop processing POST PDU if length of headers is zero;
 5174                           * this should not happen as we expect at least Content-Type. */
 5175                          if (headersLength == 0)
 5176                                  break;
 5177   
 5178                          contentTypeStart = offset;
 5179                          nextOffset = add_content_type (wsp_tree,
 5180                                          tvb, offset, &contentType, &contentTypeStr);
 5181   
 5182                          if (tree) {
 5183                                  /* Add content type to protocol summary line */
 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                                  /* Add headers subtree that will hold the headers fields */
 5193                                  /* Runs from nextOffset for
 5194                                   * headersLength - (length of content-type field) */
 5195                                  headerLength = headersLength - (nextOffset - contentTypeStart);
 5196                                  if (headerLength > 0)
 5197                                  {
 5198                                          tmp_tvb = tvb_new_subset (tvb, nextOffset,
 5199                                                          headerLength, headerLength);
 5200                                          add_headers (wsp_tree, tmp_tvb, hf_wsp_headers_section, pinfo);
 5201                                  }
 5202                                  /* XXX - offset is no longer used after this point */
 5203                                  offset = nextOffset+headerLength;
 5204                          }
 5205                          /* WSP_PDU_POST data - First check whether a subdissector exists
 5206                           * for the content type */
 5207                          if (tvb_reported_length_remaining(tvb,
 5208                                                  headerStart + count + uriLength + headersLength) > 0)
 5209                          {
 5210                                  tmp_tvb = tvb_new_subset (tvb,
 5211                                                  headerStart + count + uriLength + headersLength,
 5212                                                  -1, -1);
 5213                                  /*
 5214                                   * Try finding a dissector for the content 
 5215                                   * first, then fallback.
 5216                                   */
 5217                                  found_match = FALSE;
 5218                                  if (contentTypeStr) {
 5219                                          /*
 5220                                           * Content type is a string.
 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; /* TODO: parameters */
 5232                                                  call_dissector(media_handle, tmp_tvb, pinfo, tree);
 5233                                                  pinfo->private_data = save_private_data;
 5234  #if 0 
 5235                                                  if (tree) /* Only display if needed */
 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;      /* Initialise count */
 5246                          headersLength = tvb_get_guintvar (tvb, offset+1, &count);
 5247                          headerStart = 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)");
 5253                                  if (tree) {
 5254                                          ti = proto_tree_add_item (wsp_tree, hf_wsp_header_status,
 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))
 5261                                  { /* Append status code to INFO column */
 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)
 5269                                  ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,
 5270                                                  tvb, offset + 1, count, headersLength);
 5271   
 5272                          if (headersLength == 0)
 5273                                  break;
 5274   
 5275                          contentTypeStart = nextOffset;
 5276                          nextOffset = add_content_type (wsp_tree, tvb,
 5277                                          nextOffset, &contentType, &contentTypeStr);
 5278   
 5279                          if (tree) {
 5280                                  /* Add content type to protocol summary line */
 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                                  /* Add headers subtree that will hold the headers fields */
 5290                                  /* Runs from nextOffset for
 5291                                   * headersLength - (length of Content-Type field) */
 5292                                  headerLength = headersLength - (nextOffset - contentTypeStart);
 5293                                  if (headerLength > 0)
 5294                                  {
 5295                                          tmp_tvb = tvb_new_subset (tvb, nextOffset,
 5296                                                          headerLength, headerLength);
 5297                                          add_headers (wsp_tree, tmp_tvb, hf_wsp_headers_section, pinfo);
 5298                                  }
 5299                                  /* XXX - offset is no longer used after this point */
 5300                                  offset += count+headersLength+1;
 5301                          }
 5302                          /* WSP_PDU_REPLY data - First check whether a subdissector exists
 5303                           * for the content type */
 5304                          if (tvb_reported_length_remaining(tvb, headerStart + headersLength)
 5305                                          > 0)
 5306                          {
 5307                                  tmp_tvb = tvb_new_subset (tvb, headerStart + headersLength,
 5308                                                  -1, -1);
 5309                                  /*
 5310                                   * Try finding a dissector for the content 
 5311                                   * first, then fallback.
 5312                                   */
 5313                                  found_match = FALSE;
 5314                                  if (contentTypeStr) {
 5315                                          /*
 5316                                           * Content type is a string.
 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; /* TODO: parameters */
 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;      /* Initialise count */
 5344                          headersLength = tvb_get_guintvar (tvb, offset, &count);
 5345                          headerStart = offset + count;
 5346   
 5347                          if (tree)
 5348                                  ti = proto_tree_add_uint (wsp_tree, hf_wsp_header_length,
 5349                                                  tvb, offset, count, headersLength);
 5350   
 5351                          if (headersLength == 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                                  /* Add content type to protocol summary line */
 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                                  /* Add headers subtree that will hold the headers fields */
 5370                                  /* Runs from nextOffset for
 5371                                   * headersLength-(length of Content-Type field) */
 5372                                  headerLength = headersLength-(nextOffset-contentTypeStart);
 5373                                  if (headerLength > 0)
 5374                                  {
 5375                                          tmp_tvb = tvb_new_subset (tvb, nextOffset,
 5376                                                          headerLength, headerLength);
 5377                                          add_headers (wsp_tree, tmp_tvb, hf_wsp_headers_section, pinfo);
 5378                                  }
 5379                                  /* XXX - offset is no longer used after this point */
 5380                                  offset += headersLength;
 5381                          }
 5382                          /* WSP_PDU_PUSH data - First check whether a subdissector exists
 5383                           * for the content type */
 5384                          if (tvb_reported_length_remaining(tvb, headerStart + headersLength)
 5385                                          > 0)
 5386                          {
 5387                                  tmp_tvb = tvb_new_subset (tvb, headerStart + headersLength,
 5388                                                  -1, -1);
 5389                                  /*
 5390                                   * Try finding a dissector for the content 
 5391                                   * first, then fallback.
 5392                                   */
 5393                                  found_match = FALSE;
 5394                                  if (contentTypeStr) {
 5395                                          /*
 5396                                           * Content type is a string.
 5397                                           */
 5398                                          /*
 5399                                          if (g_ascii_strcasecmp(contentTypeStr, "application/vnd.wap.sia") == 0) {
 5400                                                  dissect_sir(tree, tmp_tvb);
 5401                                          } else 
 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; /* TODO: parameters */
 5413                                                  call_dissector(media_handle, tmp_tvb, pinfo, tree);
 5414                                                  pinfo->private_data = save_private_data;
 5415  #if 0 
 5416                                                  if (tree) /* Only display if needed */
 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  }
Show more  




Change Warning 5474.35740 : Ignored Return Value

Priority:
State:
Finding:
Owner:
Note: