Text   |  XML   |  ReML   |   Visible Warnings:

Null Pointer Dereference  at packet-kismet.c:258

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

dissect_kismet

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-kismet.c)expand/collapse
Show more  
 58  dissect_kismet(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
 59  {
 60          gboolean is_request;
 61          gboolean is_continuation;
 62          proto_tree *kismet_tree=NULL, *reqresp_tree=NULL;
 63          proto_item *ti;
 64          proto_item *tmp_item;
 65          gint offset = 0;
 66          const guchar *line;
 67          gint next_offset;
 68          int linelen;
 69          int tokenlen;
 70          int i;
 71          const guchar *next_token;
 72   
 73          /*
 74           * Find the end of the first line.
 75           *
 76           * Note that "tvb_find_line_end()" will return a value that is
 77           * not longer than what's in the buffer, so the "tvb_get_ptr()"
 78           * call won't throw an exception.
 79           */
 80[+]         linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
 81          line = tvb_get_ptr(tvb, offset, linelen);
 82   
 83          /*
 84           * Check if it is an ASCII based protocol with reasonable length 
 85           * packets, if not return, and try annother dissector.
 86           */
 87          if (linelen < 8) {
 88                  /*
 89                   * Packet is too short
 90                   */
 91                  return FALSE;
 92          } else {
 93                  for (i = 0; i < 8; ++i) {
 94                          /*
 95                           * Packet contains non-ASCII data 
 96                           */
 97                          if (line[i] < 32 || line[i] > 128)
 98                                  return FALSE;
 99                  }
 100          }
 101   
 102          /*
 103           * If it is Kismet traffic set COL_PROTOCOL.
 104           */
 105[+]         if (check_col(pinfo->cinfo, COL_PROTOCOL))
 106                  col_set_str(pinfo->cinfo, COL_PROTOCOL, "kismet");
 107   
 108          /*
 109           * Check if it is request, reply or continuation.
 110           */
 111          if (pinfo->match_port == pinfo->destport) {
 112                  is_request = TRUE;
 113                  is_continuation = FALSE;
 114          } else {
 115                  is_request = FALSE;
 116[+]                 is_continuation = response_is_continuation (line);
 117          }
 118   
 119[+]         if (check_col(pinfo->cinfo, COL_INFO)) {
 120                  /*
 121                   * Put the first line from the buffer into the summary
 122                   * if it's a kismet request or reply (but leave out the 
 123                   * line terminator).
 124                   * Otherwise, just call it a continuation.
 125                   */
 126                  if (is_continuation)
 127                          col_set_str(pinfo->cinfo, COL_INFO, "Continuation");
 128                  else 
 129                          col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",
 130                                  is_request ? "Request" : "Response",
 131                                  format_text(line, linelen));
 132          }
 133   
 134          if (tree) {
 135                  ti = proto_tree_add_item(tree, proto_kismet, tvb, offset, -1, FALSE);
 136                  kismet_tree = proto_item_add_subtree(ti, ett_kismet);
 137          }
 138   
 139          if (is_continuation) {
 140                  /*
 141                   * Put the whole packet into the tree as data.
 142                   */
 143                  call_dissector(data_handle, tvb, pinfo, kismet_tree);
 144                  return TRUE;
 145          }
 146   
 147          if (is_request) {
 148                  tmp_item = proto_tree_add_boolean(kismet_tree,
 149                                  hf_kismet_request, tvb, 0, 0, TRUE);
 150          } else {
 151                  tmp_item = proto_tree_add_boolean(kismet_tree,
 152                                  hf_kismet_response, tvb, 0, 0, TRUE);
 153          }
 154          PROTO_ITEM_SET_GENERATED (tmp_item);
 155   
 156[+]         while (tvb_offset_exists(tvb, offset)) {
 157                  /*
 158                   * Find the end of the line.
 159                   */
 160[+]                 linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
 161   
 162                  if (linelen) {
 163                          /*
 164                           * Put this line.
 165                           */
 166                          ti = proto_tree_add_text(kismet_tree, tvb, offset,
 167                                          next_offset - offset, "%s",
 168                                          tvb_format_text(tvb, offset,
 169                                          next_offset - offset - 1));
 170                          reqresp_tree = proto_item_add_subtree(ti, ett_kismet_reqresp);
 171[+]                         tokenlen = get_token_len(line, line + linelen, &next_token);
 172                          if (tokenlen != 0) {
 173                                  guint8 *reqresp;
 174                                  reqresp = tvb_get_ephemeral_string(tvb, offset, tokenlen);
 175                                  if (is_request) {
 176                                          /*
 177                                           * No request dissection 
 178                                           */
 179                                  } else {
 180                                          /*
 181                                           * *KISMET: {Version} {Start time} \001{Server name}\001 {Build Revision}
 182                                           * two fields left undocumented: {???} {?ExtendedVersion?}
 183                                           */
 184                                          if (!strncmp(reqresp, "*KISMET", 7)) {
 185                                                  offset += (gint) (next_token - line);
 186                                                  linelen -= (int) (next_token - line);
 187                                                  line = next_token;
 188                                                  tokenlen = get_token_len(line, line + linelen, &next_token);
 189                                                  proto_tree_add_text(reqresp_tree, tvb, offset,
 190                                                          tokenlen, "Kismet version: %s",
 191                                                          format_text(line, tokenlen));
 192   
 193                                                  offset += (gint) (next_token - line);
 194                                                  linelen -= (int) (next_token - line);
 195                                                  line = next_token;
 196                                                  tokenlen = get_token_len(line, line + linelen, &next_token);
 197                                                  proto_tree_add_text(reqresp_tree, tvb, offset,
 198                                                          tokenlen, "Start time: %s",
 199                                                          format_text(line, tokenlen));
 200   
 201                                                  offset += (gint) (next_token - line);
 202                                                  linelen -= (int) (next_token - line);
 203                                                  line = next_token;
 204                                                  tokenlen = get_token_len(line, line + linelen, &next_token);
 205                                                  proto_tree_add_text(reqresp_tree, tvb, offset,
 206                                                          tokenlen, "Server name: %s",
 207                                                          format_text(line + 1, tokenlen - 2));
 208   
 209                                                  offset += (gint) (next_token - line);
 210                                                  linelen -= (int) (next_token - line);
 211                                                  line = next_token;
 212                                                  tokenlen = get_token_len(line, line + linelen, &next_token);
 213                                                  proto_tree_add_text(reqresp_tree, tvb, offset,
 214                                                          tokenlen, "Build revision: %s",
 215                                                          format_text(line, tokenlen));
 216   
 217                                                  offset += (gint) (next_token - line);
 218                                                  linelen -= (int) (next_token - line);
 219                                                  line = next_token;
 220                                                  tokenlen = get_token_len(line, line + linelen, &next_token);
 221                                                  proto_tree_add_text(reqresp_tree, tvb, offset,
 222                                                          tokenlen, "Unknown field: %s",
 223                                                          format_text(line, tokenlen));
 224   
 225                                                  offset += (gint) (next_token - line);
 226                                                  linelen -= (int) (next_token - line);
 227                                                  line = next_token;
 228                                                  tokenlen = get_token_len(line, line + linelen, &next_token);
 229                                                  proto_tree_add_text(reqresp_tree, tvb, offset,
 230                                                          tokenlen,
 231                                                          "Extended version string: %s",
 232                                                          format_text(line, tokenlen));
 233                                          }
 234                                          /*
 235                                           * *TIME: {Time}
 236                                           */
 237                                          if (!strncmp(reqresp, "*TIME", 5)) {
 238                                                  time_t t;
 239                                                  char *ptr;
 240   
 241                                                  offset += (gint) (next_token - line);
 242                                                  linelen -= (int) (next_token - line);
 243                                                  line = next_token;
 244                                                  tokenlen = get_token_len(line, line + linelen, &next_token);
 245   
 246                                                  /*
 247                                                   * Convert form ascii to time_t 
 248                                                   */
 249                                                  t = atoi(format_text (line, tokenlen));
 250   
 251                                                  /*
 252                                                   * Format ascii representaion of time 
 253                                                   */
 254                                                  ptr = ctime(&t);
 255                                                  /*
 256                                                   * Delete final '\n'
 257                                                   */
 258                                                  ptr[strlen(ptr) - 1] = 0;
 259   
 260                                                  proto_tree_add_text(reqresp_tree, tvb, offset,
 261                                                          tokenlen, "Time: %s", ptr);
 262                                          }
 263                                  }
 264   
 265                                  offset += (gint) (next_token - line);
 266                                  linelen -= (int) (next_token - line);
 267                                  line = next_token;
 268                          }
 269                  }
 270                  offset = next_offset;
Show more  




Change Warning 2709.32341 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: