Text   |  XML   |  ReML   |   Visible Warnings:

Redundant Condition  at packet-eth.c:117

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

capture_eth

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-eth.c)expand/collapse
Show more  
 99  capture_eth(const guchar *pd, int offset, int len, packet_counts *ld)
 100  {
 101    guint16    etype, length;
 102    int     ethhdr_type;  /* the type of ethernet frame */
 103   
 104    if (!BYTES_ARE_IN_FRAME(offset, len, ETH_HEADER_SIZE)) {
 105      ld->other++;
 106      return;
 107    }
 108   
 109    etype = pntohs(&pd[offset+12]);
 110   
 111    if (etype <= IEEE_802_3_MAX_LEN) {
 112      /* Oh, yuck.  Cisco ISL frames require special interpretation of the 
 113         destination address field; fortunately, they can be recognized by 
 114         checking the first 5 octets of the destination address, which are
 115         01-00-0C-00-00 or 0C-00-0C-00-00 for ISL frames. */
 116      if ((pd[offset] == 0x01 || pd[offset] == 0x0C) && pd[offset+1] == 0x00 
 117          && pd[offset+2] == 0x0C && pd[offset+3] == 0x00 
 118          && pd[offset+4] == 0x00) {
 119        capture_isl(pd, offset, len, ld);
 120        return;
 121      }
 122    }
 123   
 124    /*
 125     * If the type/length field is <= the maximum 802.3 length,
 126     * and is not zero, this is an 802.3 frame, and it's a length
 127     * field; it might be an Novell "raw 802.3" frame, with no
 128     * 802.2 LLC header, or it might be a frame with an 802.2 LLC 
 129     * header.
 130     *
 131     * If the type/length field is > the maximum 802.3 length,
 132     * this is an Ethernet II frame, and it's a type field.
 133     *
 134     * If the type/length field is zero (ETHERTYPE_UNK), this is
 135     * a frame used internally by the Cisco MDS switch to contain 
 136     * Fibre Channel ("Vegas").  We treat that as an Ethernet II
 137     * frame; the dissector for those frames registers itself with
 138     * an ethernet type of ETHERTYPE_UNK.
 139     */
 140    if (etype <= IEEE_802_3_MAX_LEN && etype != ETHERTYPE_UNK) {
 141      length = etype;
 142   
 143      /* Is there an 802.2 layer? I can tell by looking at the first 2 
 144         bytes after the 802.3 header. If they are 0xffff, then what
 145         follows the 802.3 header is an IPX payload, meaning no 802.2.
 146         (IPX/SPX is they only thing that can be contained inside a
 147         straight 802.3 packet). A non-0xffff value means that there's an 
 148         802.2 layer inside the 802.3 layer */
 149      if (pd[offset+14] == 0xff && pd[offset+15] == 0xff) {
 150        ethhdr_type = ETHERNET_802_3;
 151      }
 152      else {
 153        ethhdr_type = ETHERNET_802_2;
 154      }
 155   
 156      /* Convert the LLC length from the 802.3 header to a total
 157         frame length, by adding in the size of any data that preceded
 158         the Ethernet header, and adding in the Ethernet header size,
 159         and set the payload and captured-payload lengths to the minima
 160         of the total length and the frame lengths. */
 161      length += offset + ETH_HEADER_SIZE;
 162      if (len > length)
 163        len = length;
 164    } else {
 165      ethhdr_type = ETHERNET_II;
 166    }
 167    offset += ETH_HEADER_SIZE;
 168   
 169    switch (ethhdr_type) {
 170      case ETHERNET_802_3:
 171        capture_ipx(ld);
 172        break;
 173      case ETHERNET_802_2:
 174        capture_llc(pd, offset, len, ld);
 175        break;
 176      case ETHERNET_II:
 177        capture_ethertype(etype, pd, offset, len, ld);
 178        break;
 179    }
 180  }
Show more  




Change Warning 1920.29918 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: