Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at packet-wol.c:141

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

dissect_wol

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-wol.c)expand/collapse
Show more  
 90  dissect_wol(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 91  {
 92      guint len;
 93      gint offset;
 94      guint8 sync[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 95      guint8 *mac;
 96      const guint8 *passwd;
 97   
 98  /* Set up structures needed to add the protocol subtree and manage it */
 99      proto_item *ti;
 100      proto_item *mti;
 101      proto_tree *wol_tree;
 102      proto_tree *mac_tree;
 103   
 104  /*  First, if at all possible, do some heuristics to check if the packet cannot 
 105   *  possibly belong to your protocol.  This is especially important for
 106   *  protocols directly on top of TCP or UDP where port collisions are 
 107   *  common place (e.g., even though your protocol uses a well known port,
 108   *  someone else may set up, for example, a web server on that port which,
 109   *  if someone analyzed that web server's traffic in Wireshark, would result
 110   *  in Wireshark handing an HTTP packet to your dissector).  For example:
 111   */
 112      /* Check that there's enough data */
 113      len = tvb_length(tvb);
 114      if ( len < 102 )    /* wol's smallest packet size is 102 */
 115          return (0);
 116   
 117      /* Get some values from the packet header, probably using tvb_get_*() */
 118   
 119      /* Regardless of what the AMD white paper states, don't search the entire 
 120       * tvb for the synchronization stream.  My feeling is that this could be
 121       * quite expensive and seriously hinder Wireshark performance.  For now,
 122       * unless we need to change it later, just compare the 1st 6 bytes. */
 123      if ( tvb_memeql(tvb, 0, sync, 6) != 0 )
 124          return (0);
 125   
 126      /* So far so good.  Now get the next 6 bytes, which we'll assume is the 
 127       * target's MAC address, and do 15 memory chunk comparisons, since if this 
 128       * is a real MagicPacket, the target's MAC will be duplicated 16 times. */
 129      mac = ep_tvb_memdup(tvb, 6, 6);
 130      for ( offset = 12; offset < 102; offset += 6 )
 131          if ( tvb_memeql(tvb, offset, mac, 6) != 0 )
 132              return (0);
 133   
 134      /* OK, we're going to assume it's a MagicPacket.  If there's a password,
 135       * grab it now, and in case there's any extra bytes after the only 3 valid
 136       * and expected lengths, truncate the length so the extra byte(s) aren't
 137       * included as being part of the WOL payload. */
 138      if ( len >= 106 && len < 108 )
 139      {
 140          len = 106;
 141          passwd = ip_to_str(ep_tvb_memdup(tvb, 102, 4));
 142      }
 143      else if ( len >= 108 )
 144      {
 145          len = 108;
 146          passwd = ether_to_str(ep_tvb_memdup(tvb, 102, 6));
 147      }
 148      else 
 149      {
 150          len = 102;
 151          passwd = NULL;
 152      }
 153   
 154  /* Make entries in Protocol column and Info column on summary display */
 155      if (check_col(pinfo->cinfo, COL_PROTOCOL))
 156          col_set_str(pinfo->cinfo, COL_PROTOCOL, "WOL");
 157   
 158  /* This field shows up as the "Info" column in the display; you should use 
 159     it, if possible, to summarize what's in the packet, so that a user looking 
 160     at the list of packets can tell what type of packet it is. See section 1.5
 161     for more information.
 162   
 163     Before changing the contents of a column you should make sure the column is 
 164     active by calling "check_col(pinfo->cinfo, COL_*)". If it is not active 
 165     don't bother setting it.
 166   
 167
178
Show [ Lines 167 to 178 omitted. ]
 179     the Info column, clear that column first, in case the calls to fetch
 180     data from the packet throw an exception because they're fetching data
 181     past the end of the packet, so that the Info column doesn't have data
 182     left over from the previous dissector; do 
 183   
 184      if (check_col(pinfo->cinfo, COL_INFO))
 185          col_clear(pinfo->cinfo, COL_INFO);
 186   
 187     */
 188   
 189      if ( check_col(pinfo->cinfo, COL_INFO) )
 190      {
 191          col_clear(pinfo->cinfo, COL_INFO);
 192          col_add_fstr(pinfo->cinfo, COL_INFO, "MagicPacket for %s (%s)",
 193              get_ether_name(mac), ether_to_str(mac));
 194   
 195          /* NOTE: ether-wake uses a dotted-decimal format for specifying a
 196           * 4-byte password or an Ethernet mac address format for specifying 
 197           * a 6-byte password, so display them in that format, even if the 
 198           * password isn't really an IP or MAC address. */
 199          if ( passwd )
 200              col_append_fstr(pinfo->cinfo, COL_INFO, ", password %s", passwd);
 201      }
 202   
 203  /* A protocol dissector can be called in 2 different ways:
 204   
 205      (a) Operational dissection
 206   
 207          In this mode, Wireshark is only interested in the way protocols
 208          interact, protocol conversations are created, packets are
 209          reassembled and handed over to higher-level protocol dissectors.
 210          In this mode Wireshark does not build a so-called "protocol
 211
230
Show [ Lines 211 to 230 omitted. ]
 231     the protocol tree can be passed a null protocol tree pointer, in 
 232     which case they'll return a null item pointer, and 
 233     "proto_item_add_subtree()" returns a null tree pointer if passed a
 234     null item pointer, so, if you're careful not to dereference any null
 235     tree or item pointers, you can accomplish this by doing all the
 236     dissection work.  This might not be as efficient as skipping that
 237     work if you're not building a protocol tree, but if the code would 
 238     have a lot of tests whether "tree" is null if you skipped that work,
 239     you might still be better off just doing all that work regardless of
 240     whether "tree" is null or not. */
 241      if (tree) {
 242   
 243  /* NOTE: The offset and length values in the call to 
 244     "proto_tree_add_item()" define what data bytes to highlight in the hex 
 245     display window when the line in the protocol tree display 
 246     corresponding to that item is selected.
 247   
 248     Supplying a length of -1 is the way to highlight all data from the 
 249     offset to the end of the packet. */
 250   
 251  /* create display subtree for the protocol */
 252          ti = proto_tree_add_item(tree, proto_wol, tvb, 0, len, FALSE);
 253          proto_item_append_text(ti, ", MAC: %s (%s)", get_ether_name(mac),
 254              ether_to_str(mac));
 255          if ( passwd )
 256              proto_item_append_text(ti, ", password: %s", passwd);
 257          wol_tree = proto_item_add_subtree(ti, ett_wol);
 258   
 259  /* add an item to the subtree, see section 1.6 for more information */
 260          proto_tree_add_item(wol_tree, hf_wol_sync, tvb, 0, 6, FALSE);
 261   
 262  /* Continue adding tree items to process the packet here */
 263          mti = proto_tree_add_text(wol_tree, tvb, 6, 96, "MAC: %s (%s)",
 264              get_ether_name(mac), ether_to_str(mac));
 265          mac_tree = proto_item_add_subtree(mti, ett_wol_macblock);
 266          for ( offset = 6; offset < 102; offset += 6 )
 267              proto_tree_add_ether(mac_tree, hf_wol_mac, tvb, offset, 6, mac);
 268   
 269          if ( len == 106 )
 270              proto_tree_add_bytes_format(wol_tree, hf_wol_passwd, tvb, offset,
 271                  4, passwd, "Password: %s", passwd);
 272          else if ( len == 108 )
 273              proto_tree_add_bytes_format(wol_tree, hf_wol_passwd, tvb, offset,
 274                  6, passwd, "Password: %s", passwd);
 275      }
 276   
 277  /* If this protocol has a sub-dissector call it here, see section 1.8 */
 278   
 279  /* Return the amount of data this dissector was able to dissect */
 280      if ( pinfo->ethertype == ETHERTYPE_WOL )
 281          return (len);
 282   
 283      /* Heuristic dissectors return TRUE/FALSE. */
 284      return (TRUE);
 285  }
Show more  




Change Warning 5461.35681 : Ignored Return Value

Priority:
State:
Finding:
Owner:
Note: