Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at packet-dcc.c:236

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

dissect_dcc

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-dcc.c)expand/collapse
Show more  
 212  dissect_dcc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 213  {
 214          proto_tree      *dcc_tree, *dcc_optree, *dcc_opnumtree, *ti;
 215          proto_tree *dcc_tracetree;
 216          proto_item *hidden_item;
 217          int offset = 0;
 218          int client_is_le = 0;
 219          int op = 0;
 220          int i, is_response;
 221   
 222          if (pinfo->srcport != DCC_PORT && pinfo->destport != DCC_PORT) {
 223                  /* Not the right port - not a DCC packet. */
 224                  return FALSE;
 225          }
 226   
 227          /* get at least a full packet structure */
 228          if ( tvb_length(tvb) < sizeof(DCC_HDR) ) {
 229                  /* Doesn't have enough bytes to contain packet header. */
 230                  return FALSE;
 231          }
 232   
 233          if (check_col(pinfo->cinfo, COL_PROTOCOL))
 234                  col_set_str(pinfo->cinfo, COL_PROTOCOL, "DCC");
 235   
 236          offset = 0;
 237          is_response = pinfo->srcport == DCC_PORT;
 238   
 239          if (check_col(pinfo->cinfo, COL_INFO)) {
 240                  col_add_fstr(pinfo->cinfo, COL_INFO,
 241                          "%s: %s",
 242                          is_response ? "Response" : "Request",
 243                          val_to_str(tvb_get_guint8(tvb, offset+3),
 244                                   dcc_op_vals, "Unknown Op: %u")
 245                  );
 246          }
 247   
 248          if (tree) {
 249                  ti = proto_tree_add_item(tree, proto_dcc, tvb, offset, -1,
 250                          FALSE);
 251                  dcc_tree = proto_item_add_subtree(ti, ett_dcc);
 252   
 253                  proto_tree_add_item(dcc_tree, hf_dcc_len, tvb,
 254                          offset, 2, FALSE);
 255   
 256                  if ( tvb_length(tvb) < tvb_get_ntohs(tvb, offset)) {
 257                          /* Doesn't have number of bytes that header claims. */
 258                          proto_tree_add_text(dcc_tree, tvb, offset, 2, "Error - packet is shorter than header claims!");
 259                  }
 260                  offset += 2;
 261   
 262                  proto_tree_add_item(dcc_tree, hf_dcc_pkt_vers, tvb,
 263                          offset, 1, FALSE);
 264                  offset += 1;
 265   
 266                  op = tvb_get_guint8(tvb, offset);
 267                  proto_tree_add_item(dcc_tree, hf_dcc_op, tvb,
 268                          offset, 1, FALSE);
 269                  offset += 1;
 270   
 271                  proto_tree_add_item(dcc_tree, hf_dcc_clientid, tvb,
 272                          offset, 4, FALSE);
 273                  offset += 4;
 274   
 275                  ti = proto_tree_add_text(dcc_tree, tvb, offset, -1, "Operation Numbers (Opaque to Server)");
 276                  dcc_opnumtree = proto_item_add_subtree(ti, ett_dcc_opnums);
 277   
 278                  /* Note - these are indeterminate - they are sortof considered opaque to the client */
 279                  /* Make some attempt to figure out if this data is little endian, not guaranteed to be
 280                  correct if connection went through a firewall or similar. */
 281   
 282                  /* Very hokey check - if all three of pid/report/retrans look like little-endian
 283                          numbers, host is probably little endian. Probably innacurate on super-heavily-used
 284                          DCC clients though. This should be good enough for now. */
 285                  client_is_le = ( (tvb_get_guint8(tvb, offset+4) | tvb_get_guint8(tvb, offset+4)) &&
 286                                                   (tvb_get_guint8(tvb, offset+8) | tvb_get_guint8(tvb, offset+9)) &&
 287                                                   (tvb_get_guint8(tvb, offset+12) | tvb_get_guint8(tvb, offset+13)) );
 288   
 289                  proto_tree_add_item(dcc_opnumtree, hf_dcc_opnums_host, tvb,
 290                          offset, 4, client_is_le);
 291                  offset += 4;
 292   
 293                  proto_tree_add_item(dcc_opnumtree, hf_dcc_opnums_pid, tvb,
 294                          offset, 4, client_is_le);
 295                  offset += 4;
 296   
 297                  proto_tree_add_item(dcc_opnumtree, hf_dcc_opnums_report, tvb,
 298                          offset, 4, client_is_le);
 299                  offset += 4;
 300   
 301                  proto_tree_add_item(dcc_opnumtree, hf_dcc_opnums_retrans, tvb,
 302                          offset, 4, client_is_le);
 303                  offset += 4;
 304   
 305                  ti = proto_tree_add_text(dcc_tree, tvb, offset, -1, "Operation: %s",
 306                          val_to_str(op, dcc_op_vals, "Unknown Op: %u"));
 307                  dcc_optree = proto_item_add_subtree(ti, ett_dcc_op);
 308   
 309                  switch(op) {
 310                          case DCC_OP_NOP:
 311                                  D_SIGNATURE();
 312                                  break;
 313   
 314                          case DCC_OP_REPORT:
 315                                  D_TARGET();
 316                                  for (i=0; i<=DCC_QUERY_MAX &&
 317                                          tvb_bytes_exist(tvb, offset+sizeof(DCC_SIGNATURE),1); i++)
 318                                  {
 319                                          D_CHECKSUM();
 320                                  }
 321                                  D_SIGNATURE();
 322                                  break;
 323   
 324                          case DCC_OP_QUERY_RESP:
 325                                  for (i=0; i<=DCC_QUERY_MAX &&
 326                                          tvb_bytes_exist(tvb, offset+sizeof(DCC_SIGNATURE),1); i++)
 327                                  {
 328                                          D_TARGET();
 329                                  }
 330                                  D_SIGNATURE();
 331                                  break;
 332   
 333                          case DCC_OP_ADMN:
 334                                  if ( is_response )
 335                                  {
 336                                          int left_local = tvb_length_remaining(tvb, offset) -
 337                                                  sizeof(DCC_SIGNATURE);
 338                                          if ( left_local == sizeof(DCC_ADMN_RESP_CLIENTS) )
 339                                          {
 340                                                  D_LABEL("Addr", 16);
 341                                                  D_LABEL("Id", sizeof(DCC_CLNT_ID));
 342                                                  D_LABEL("Last Used", 4);
 343                                                  D_LABEL("Requests", 4);
 344                                          }
 345                                          else 
 346                                          {
 347                                                  D_TEXT("Response Text", sizeof(DCC_SIGNATURE));
 348                                          }
 349                                          D_SIGNATURE();
 350                                  }
 351                                  else 
 352                                  {
 353                                          int aop;
 354   
 355                                          D_DATE();
 356   
 357                                          aop = tvb_get_guint8(tvb, offset+4);
 358                                          proto_tree_add_item(dcc_optree, hf_dcc_adminop, tvb, offset+4,
 359                                                  1, FALSE);
 360                                          if (check_col(pinfo->cinfo, COL_INFO)) {
 361                                                  col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
 362                                                          val_to_str(tvb_get_guint8(tvb,offset+4),
 363                                                          dcc_adminop_vals, "Unknown (%u)"));
 364                                          }
 365   
 366                                          if (aop == DCC_AOP_TRACE_ON || aop == DCC_AOP_TRACE_OFF )
 367                                          {
 368                                                  ti = proto_tree_add_item(dcc_optree, hf_dcc_trace, tvb, offset,
 369                                                          4, FALSE);
 370                                                  dcc_tracetree = proto_item_add_subtree(ti, ett_dcc_trace);
 371                                                  proto_tree_add_item(dcc_tracetree, hf_dcc_trace_admin, tvb, offset, 4, FALSE);
 372                                                  proto_tree_add_item(dcc_tracetree, hf_dcc_trace_anon, tvb, offset, 4, FALSE);
 373                                                  proto_tree_add_item(dcc_tracetree, hf_dcc_trace_client, tvb, offset, 4, FALSE);
 374                                                  proto_tree_add_item(dcc_tracetree, hf_dcc_trace_rlim, tvb, offset, 4, FALSE);
 375                                                  proto_tree_add_item(dcc_tracetree, hf_dcc_trace_query, tvb, offset, 4, FALSE);
 376                                                  proto_tree_add_item(dcc_tracetree, hf_dcc_trace_ridc, tvb, offset, 4, FALSE);
 377                                                  proto_tree_add_item(dcc_tracetree, hf_dcc_trace_flood, tvb, offset, 4, FALSE);
 378                                          }
 379                                          else if ( aop == DCC_AOP_FLOD )
 380                                          {
 381                                                  proto_tree_add_item(dcc_optree, hf_dcc_floodop,
 382                                                          tvb, offset, 4, FALSE);
 383                                                  if (check_col(pinfo->cinfo, COL_INFO)) {
 384                                                          col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
 385                                                                  val_to_str(tvb_get_ntohl(tvb,offset),
 386                                                                  dcc_floodop_vals, "Unknown (%u)"));
 387                                                  }
 388                                          }
 389                                          else 
 390                                          {
 391                                                  proto_tree_add_item(dcc_optree, hf_dcc_adminval,
 392                                                          tvb, offset, 4, FALSE);
 393                                          }
 394                                          offset += 4;
 395   
 396                                          offset += 1; /* admin op we did in reverse order */
 397                                          D_LABEL("Pad", 3);
 398                                          D_SIGNATURE();
 399                                  }
 400                                  break;
 401   
 402                          case DCC_OP_OK:
 403                                  proto_tree_add_item(dcc_optree, hf_dcc_max_pkt_vers, tvb,
 404                                          offset, 1, FALSE);
 405                                  offset += 1;
 406   
 407                                  D_LABEL("Unused", 1);
 408   
 409                                  proto_tree_add_item(dcc_optree, hf_dcc_qdelay_ms, tvb,
 410                                          offset, 2, FALSE);
 411                                  offset += 2;
 412   
 413                                  proto_tree_add_item(dcc_optree, hf_dcc_brand, tvb,
 414                                          offset, sizeof(DCC_BRAND), FALSE);
 415                                  offset += sizeof(DCC_BRAND);
 416   
 417                                  D_SIGNATURE();
 418                                  break;
 419   
 420                          default:
 421                                  /* do nothing */
 422                                  break;
 423                  }
 424          }
 425   
 426          return TRUE;
 427  }
Show more  




Change Warning 1988.32299 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: