Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at packet-lldp.c:590

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

dissect_lldp_chassis_id

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-lldp.c)expand/collapse
Show more  
 515  dissect_lldp_chassis_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset)
 516  {
 517          guint8 tempType;
 518          guint16 tempShort;
 519          guint32 tempLen = 0;
 520          const char *strPtr=NULL;
 521          guint8 incorrectLen = 0;        /* incorrect length if 1 */
 522   
 523          const guint8 *mac_addr = NULL;
 524          guint32 ip_addr;
 525          struct e_in6_addr ip6_addr;
 526          guint8 addr_family = 0;
 527   
 528          proto_tree      *chassis_tree = NULL;
 529          proto_item      *tf = NULL;
 530   
 531          /* Get tlv type */
 532          tempShort = tvb_get_ntohs(tvb, offset);
 533          tempType = TLV_TYPE(tempShort);
 534          if (tempType != CHASSIS_ID_TLV_TYPE)
 535          {
 536                  if (tree)
 537                  {
 538                          tf = proto_tree_add_text(tree, tvb, offset, 2, "Invalid Chassis ID (0x%02X)", tempType);
 539                          chassis_tree = proto_item_add_subtree(tf, ett_chassis_id);
 540                          proto_tree_add_text(chassis_tree, tvb, offset, 2, "%s Invalid Chassis ID (%u)",
 541                                                  decode_boolean_bitfield(tempType, TLV_TYPE_MASK, 16, "", ""), tempType);
 542                  }
 543   
 544                  return -1;
 545          }
 546   
 547          /* Get tlv length */
 548          tempLen = TLV_INFO_LEN(tempShort);
 549          if (tempLen < 2)
 550          {
 551                  if (tree)
 552                  {
 553                          tf = proto_tree_add_text(tree, tvb, offset, 2, "Invalid Chassis ID Length (%u)", tempLen);
 554                          chassis_tree = proto_item_add_subtree(tf, ett_chassis_id);
 555                          proto_tree_add_item(chassis_tree, hf_lldp_tlv_type, tvb, offset, 2, FALSE);
 556                          proto_tree_add_text(chassis_tree, tvb, offset, 2, "%s Invalid Length: %u",
 557                                                  decode_boolean_bitfield(tempLen, TLV_INFO_LEN_MASK, 16, "", ""), tempLen);
 558                  }
 559   
 560                  return -1;
 561          }
 562   
 563          /* Get tlv subtype */
 564          tempType = tvb_get_guint8(tvb, (offset+2));
 565   
 566          switch (tempType)
 567          {
 568          case 4: /* MAC address */
 569          {
 570                  if (tempLen != 7)
 571                  {
 572                          incorrectLen = 1;       /* Invalid length */
 573                          break;
 574                  }
 575   
 576                  mac_addr=tvb_get_ptr(tvb, (offset+3), 6);
 577                  strPtr = ether_to_str(mac_addr);
 578   
 579                  break;
 580          }
 581          case 5: /* Network address */
 582          {
 583                  /* Get network address family */
 584                  addr_family = tvb_get_guint8(tvb,offset+3);
 585                  /* Check for IPv4 or IPv6 */
 586                  switch(addr_family){
 587                  case AFNUM_INET:
 588                          if (tempLen == 6){
 589                                  ip_addr = tvb_get_ipv4(tvb, (offset+4));
 590                                  strPtr = ip_to_str((guint8 *)&ip_addr);
 591                          }else{
 592                                  incorrectLen = 1;       /* Invalid length */
 593                          }
 594                          break;
 595                  case AFNUM_INET6:
 596                          if  (tempLen == 18){
 597                                  tvb_get_ipv6(tvb, (offset+4), &ip6_addr);
 598                                  strPtr = ip6_to_str(&ip6_addr);
 599                          }else{
 600                                  incorrectLen = 1;       /* Invalid length */
 601                          }
 602                          break;
 603                  default:
 604                          strPtr = tvb_bytes_to_str(tvb, (offset+4), (tempLen-2));
 605                          break;
 606                  }
 607                  break;
 608          }
 609          case 2: /* Interface alias */
 610          case 6: /* Interface name */
 611          case 7: /* Locally assigned */
 612          {
 613                  if (tempLen > 256)
 614                  {
 615                          incorrectLen = 1;       /* Invalid length */
 616                          break;
 617                  }
 618   
 619                  strPtr = tvb_format_stringzpad(tvb, (offset+3), (tempLen-1));
 620   
 621                  break;
 622          }
 623          case 1: /* Chassis component */
 624          case 3: /* Port component */
 625          {
 626                  if (tempLen > 256)
 627                  {
 628                          incorrectLen = 1;       /* Invalid length */
 629                          break;
 630                  }
 631   
 632                  strPtr = tvb_bytes_to_str(tvb, (offset+3), (tempLen-1));
 633                  break;
 634          }
 635          default:        /* Reserved types */
 636          {
 637                  if (tempLen > 256)
 638                  {
 639                          incorrectLen = 1;       /* Invalid length */
 640                          break;
 641                  }
 642   
 643                  strPtr = "Reserved";
 644   
 645                  break;
 646          }
 647          }
 648   
 649          if (incorrectLen == 1)
 650          {
 651                  if (tree)
 652                  {
 653                          tf = proto_tree_add_text(tree, tvb, offset, 2, "Invalid Chassis ID Length (%u)", tempLen);
 654                          chassis_tree = proto_item_add_subtree(tf, ett_chassis_id);
 655                          proto_tree_add_item(chassis_tree, hf_lldp_tlv_type, tvb, offset, 2, FALSE);
 656                          proto_tree_add_text(chassis_tree, tvb, offset, 2, "%s Invalid Length: %u",
 657                                                  decode_boolean_bitfield(tempLen, TLV_INFO_LEN_MASK, 16, "", ""), tempLen);
 658                          /* Get chassis id subtype */
 659                          proto_tree_add_item(chassis_tree, hf_chassis_id_subtype, tvb, (offset+2), 1, FALSE);
 660   
 661                  }
 662   
 663                  return -1;
 664          }
 665   
 666          if (check_col(pinfo->cinfo, COL_INFO))
 667                  col_add_fstr(pinfo->cinfo, COL_INFO, "Chassis Id = %s ", strPtr);
 668   
 669          if (tree)
 670          {
 671                  /* Set chassis tree */
 672                  tf = proto_tree_add_text(tree, tvb, offset, (tempLen + 2), "Chassis Subtype = %s",
 673                                                                  val_to_str(tempType, chassis_id_subtypes, "Reserved" ));
 674                  chassis_tree = proto_item_add_subtree(tf, ett_chassis_id);
 675   
 676                  proto_tree_add_item(chassis_tree, hf_lldp_tlv_type, tvb, offset, 2, FALSE);
 677                  proto_tree_add_item(chassis_tree, hf_lldp_tlv_len, tvb, offset, 2, FALSE);
 678   
 679                  /* Get chassis id subtype */
 680                  proto_tree_add_item(chassis_tree, hf_chassis_id_subtype, tvb, (offset+2), 1, FALSE);
 681   
 682                  /* Get chassis id */
 683                  switch (tempType)
 684                  {
 685                  case 4: /* MAC address */
 686                          proto_tree_add_ether(chassis_tree, hf_chassis_id_mac, tvb, (offset+3), 6, mac_addr);
 687                          proto_item_append_text(tf, ", Id: %s", strPtr);
 688                          break;
 689                  case 5: /* Network address */
 690                          proto_tree_add_item(chassis_tree, hf_lldp_network_address_family, tvb, offset+3, 1, FALSE);
 691                          switch(addr_family){
 692                          case AFNUM_INET:
 693                                  proto_tree_add_ipv4(chassis_tree, hf_chassis_id_ip4, tvb, (offset+4), 4, ip_addr);
 694                                  break;
 695                          case AFNUM_INET6:
 696                                  proto_tree_add_ipv6(chassis_tree, hf_chassis_id_ip6, tvb, (offset+4), 16, ip6_addr.bytes);
 697                                  break;
 698                          default:
 699                                  proto_tree_add_text(chassis_tree, tvb, (offset+4), (tempLen-2), "Chassis Id: %s", strPtr);
 700                                  break;
 701                          }
 702                          break;
 703                  case 2: /* Interface alias */
 704                  case 6: /* Interface name */
 705                  case 7: /* Locally assigned */
 706                          proto_tree_add_text(chassis_tree, tvb, (offset+3), (tempLen-1), "Chassis Id: %s", strPtr);
 707                          proto_item_append_text(tf, ", Id: %s", strPtr);
 708                          break;
 709                  case 1: /* Chassis component */
 710                  case 3: /* Port component */
 711                          proto_tree_add_item(chassis_tree, hf_chassis_id, tvb, (offset+3), (tempLen-1), FALSE);
 712                          break;
 713                  }
 714          }
 715   
 716          return (tempLen + 2);
 717  }
Show more  




Change Warning 5463.35683 : Ignored Return Value

Because they are very similar, this warning shares annotations with warnings 5463.35695 and 5463.35696.

Priority:
State:
Finding:
Owner:
Note: