Text   |  XML   |  ReML   |   Visible Warnings:

Null Pointer Dereference  at packet-ncp2222.inc:7724

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

dissect_ncp_common

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ncp.c)expand/collapse
Show more  
 302  dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 303      gboolean is_tcp)
 304  {
 305      proto_tree            *ncp_tree = NULL;
 306      proto_item            *ti;
 307      struct ncp_ip_header  ncpiph;
 308      struct ncp_ip_rqhdr   ncpiphrq;
 309      guint16               ncp_burst_seqno, ncp_ack_seqno;
 310      guint16               flags = 0;
 311      proto_tree            *flags_tree = NULL;
 312      int                   hdr_offset = 0;
 313      int                   commhdr = 0;
 314      int                   offset = 0;
 315      gint                  length_remaining;
 316      tvbuff_t              *next_tvb;
 317      guint32               testvar = 0, ncp_burst_command, burst_len, burst_off, burst_file;
 318      guint8                subfunction;
 319      guint32               nw_connection = 0, data_offset;
 320      guint16               data_len = 0;
 321      guint16               missing_fraglist_count = 0;
 322      mncp_rhash_value      *request_value = NULL;
 323      conversation_t        *conversation;
 324      proto_item            *expert_item;
 325   
 326      if (check_col(pinfo->cinfo, COL_PROTOCOL))
 327          col_set_str(pinfo->cinfo, COL_PROTOCOL, "NCP");
 328[+]     if (check_col(pinfo->cinfo, COL_INFO))
 329          col_clear(pinfo->cinfo, COL_INFO);
 330   
 331      hdr_offset = 0;
 332      ncp_hdr = &header;
 333      commhdr = hdr_offset;
 334   
 335      ti = proto_tree_add_item(tree, proto_ncp, tvb, 0, -1, FALSE);
 336[+]     ncp_tree = proto_item_add_subtree(ti, ett_ncp);
 337      if (is_tcp) {
 338          if (tvb_get_ntohl(tvb, hdr_offset) != NCPIP_RQST && tvb_get_ntohl(tvb, hdr_offset) != NCPIP_RPLY)
 339              commhdr += 1;
 340          /* Get NCPIP Header data */
 341          ncpiph.signature = tvb_get_ntohl(tvb, commhdr);
 342          proto_tree_add_uint(ncp_tree, hf_ncp_ip_sig, tvb, commhdr, 4, ncpiph.signature);
 343          ncpiph.length = (0x7fffffff & tvb_get_ntohl(tvb, commhdr+4));
 344          proto_tree_add_uint(ncp_tree, hf_ncp_ip_length, tvb, commhdr+4, 4, ncpiph.length);
 345          commhdr += 8;
 346          if (ncpiph.signature == NCPIP_RQST) {
 347              ncpiphrq.version = tvb_get_ntohl(tvb, commhdr);
 348              proto_tree_add_uint(ncp_tree, hf_ncp_ip_ver, tvb, commhdr, 4, ncpiphrq.version);
 349              commhdr += 4;
 350              ncpiphrq.rplybufsize = tvb_get_ntohl(tvb, commhdr);
 351              proto_tree_add_uint(ncp_tree, hf_ncp_ip_rplybufsize, tvb, commhdr, 4, ncpiphrq.rplybufsize);
 352              commhdr += 4;
 353          }
 354          /* Check to see if this is a valid offset, otherwise increment for packet signature */
 355          if (match_strval(tvb_get_ntohs(tvb, commhdr), ncp_type_vals)==NULL) {
 356              /* Check to see if we have a valid type after packet signature length */
 357              if (match_strval(tvb_get_ntohs(tvb, commhdr+8), ncp_type_vals)!=NULL) {
 358                  proto_tree_add_item(ncp_tree, hf_ncp_ip_packetsig, tvb, commhdr, 8, FALSE);
 359                  commhdr += 8;
 360              }
 361          }
 362      } else {
 363          /* Initialize this structure, we use it below */
 364          memset(&ncpiph, 0, sizeof(ncpiph));
 365      }
 366   
 367      header.type         = tvb_get_ntohs(tvb, commhdr);
 368      header.sequence     = tvb_get_guint8(tvb, commhdr+2);
 369      header.conn_low     = tvb_get_guint8(tvb, commhdr+3);
 370      header.task         = tvb_get_guint8(tvb, commhdr+4);
 371      header.conn_high    = tvb_get_guint8(tvb, commhdr+5);
 372      proto_tree_add_uint(ncp_tree, hf_ncp_type, tvb, commhdr, 2, header.type);
 373      nw_connection = (header.conn_high*256)+header.conn_low;
 374   
 375      /* Ok, we need to track the conversation so that we can
 376       * determine if a new server session is occuring for this
 377       * connection.
 378       */
 379      conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
 380          PT_NCP, (guint32) pinfo->srcport, (guint32) pinfo->destport,
 381          0);
 382      if ((ncpiph.length & 0x80000000) || ncpiph.signature == NCPIP_RPLY) {
 383          /* First time through we will record the initial connection and task 
 384           * values 
 385           */
 386          if (!pinfo->fd->flags.visited) {
 387              if (conversation != NULL) {
 388                  /* find the record telling us the
 389                   * request made that caused this 
 390                   * reply 
 391                   */
 392                  request_value = mncp_hash_lookup(conversation, nw_connection, header.task);
 393
417
Show [ Lines 393 to 417 omitted. ]
 418          } else {
 419              /* Get request value data */
 420              request_value = mncp_hash_lookup(conversation, nw_connection, header.task);
 421              if (request_value) {
 422                  if ((request_value->session_start_packet_num == pinfo->fd->num) && ncp_echo_conn)
 423                  {
 424                      expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Detected New Server Session. Connection %d, Task %d", nw_connection, header.task);
 425                  }
 426              }
 427          }
 428      } else {
 429          if (!pinfo->fd->flags.visited) {
 430              if (conversation != NULL) {
 431                  /* find the record telling us the
 432                   * request made that caused this 
 433                   * reply 
 434                   */
 435                  request_value = mncp_hash_lookup(conversation, nw_connection, header.task);
 436                  /* if for some reason we have no 
 437                   * conversation in our hash, create 
 438                   * one */
 439                  if (request_value == NULL) {
 440                      request_value = mncp_hash_insert(conversation, nw_connection, header.task, pinfo);
 441                  }
 442              } else {
 443                  /* It's not part of any conversation 
 444                   * - create a new one.
 445                   */
 446                  conversation = conversation_new(pinfo->fd->num, &pinfo->src,
 447                      &pinfo->dst, PT_NCP, (guint32) pinfo->srcport, (guint32) pinfo->destport, 0);
 448                  request_value = mncp_hash_insert(conversation, nw_connection, header.task, pinfo);
 449              }
 450              /* find the record telling us the request 
 451               * made that caused this reply 
 452               */
 453          } else {
 454              request_value = mncp_hash_lookup(conversation, nw_connection, header.task);
 455              if (request_value) {
 456                  if ((request_value->session_start_packet_num == pinfo->fd->num) && ncp_echo_conn)
 457                  {
 458                      expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Detected New Server Session. Connection %d, Task %d", nw_connection, header.task);
 459                  }
 460              }
 461          }
 462      }
 463   
 464      tap_queue_packet(ncp_tap.hdr, pinfo, ncp_hdr);
 465   
 466      if (check_col(pinfo->cinfo, COL_INFO)) {
 467          col_add_str(pinfo->cinfo, COL_INFO,
 468              val_to_str(header.type, ncp_type_vals, "Unknown type (0x%04x)"));
 469      }
 470   
 471      /*
 472       * Process the packet-type-specific header.
 473       */
 474      switch (header.type) {
 475   
 476      case NCP_BROADCAST_SLOT:    /* Server Broadcast */
 477          proto_tree_add_uint(ncp_tree, hf_ncp_seq, tvb, commhdr + 2, 1, header.sequence);
 478          proto_tree_add_uint(ncp_tree, hf_ncp_connection,tvb, commhdr + 3, 3, nw_connection);
 479          proto_tree_add_item(ncp_tree, hf_ncp_task, tvb, commhdr + 4, 1, FALSE);
 480          proto_tree_add_item(ncp_tree, hf_ncp_oplock_flag, tvb, commhdr + 9, 1, tvb_get_guint8(tvb, commhdr+9));
 481          proto_tree_add_item(ncp_tree, hf_ncp_oplock_handle, tvb, commhdr + 10, 4, FALSE);
 482          if ((tvb_get_guint8(tvb, commhdr+9)==0x24) && ncp_echo_file)
 483          {
 484              expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Server requesting station to clear oplock on handle - %08x", tvb_get_ntohl(tvb, commhdr+10));
 485
668
Show [ Lines 485 to 668 omitted. ]
 669          if (length_remaining > 4) {
 670              testvar = tvb_get_ntohl(tvb, commhdr+4);
 671              if (testvar == 0x4c495020) {
 672                  proto_tree_add_item(ncp_tree, hf_lip_echo, tvb, commhdr+4, 13, FALSE);
 673                  break;
 674              }
 675          }
 676          /* otherwise fall through */
 677   
 678      case NCP_POSITIVE_ACK:        /* Positive Acknowledgement */
 679      case NCP_SERVICE_REQUEST:    /* Server NCP Request */
 680      case NCP_SERVICE_REPLY:        /* Server NCP Reply */
 681      case NCP_WATCHDOG:        /* Watchdog Packet */
 682      case NCP_DEALLOCATE_SLOT:    /* Deallocate Slot Request */
 683      default:
 684          proto_tree_add_uint(ncp_tree, hf_ncp_seq, tvb, commhdr + 2, 1, header.sequence);
 685          proto_tree_add_uint(ncp_tree, hf_ncp_connection,tvb, commhdr + 3, 3, nw_connection);
 686          proto_tree_add_item(ncp_tree, hf_ncp_task, tvb, commhdr + 4, 1, FALSE);
 687          break;
 688      }
 689   
 690      /*
 691       * Process the packet body.
 692       */
 693      switch (header.type) {
 694   
 695      case NCP_ALLOCATE_SLOT:        /* Allocate Slot Request */
 696          length_remaining = tvb_length_remaining(tvb, commhdr + 4);
 697          if (length_remaining > 4) {
 698              testvar = tvb_get_ntohl(tvb, commhdr+4);
 699              if (testvar == 0x4c495020) {
 700                  proto_tree_add_text(ncp_tree, tvb, commhdr, -1,
 701                      "Lip Echo Packet");
 702                  /*break;*/
 703              }
 704          }
 705          next_tvb = tvb_new_subset(tvb, commhdr, -1, -1);
 706          dissect_ncp_request(next_tvb, pinfo, nw_connection,
 707              header.sequence, header.type, ncp_tree);
 708          break;
 709   
 710      case NCP_DEALLOCATE_SLOT:    /* Deallocate Slot Request */
 711          next_tvb = tvb_new_subset(tvb, commhdr, -1, -1);
 712          dissect_ncp_request(next_tvb, pinfo, nw_connection,
 713              header.sequence, header.type, ncp_tree);
 714          break;
 715   
 716      case NCP_SERVICE_REQUEST:    /* Server NCP Request */
 717      case NCP_BROADCAST_SLOT:    /* Server Broadcast Packet */
 718          next_tvb = tvb_new_subset(tvb, commhdr, -1, -1);
 719[+]         if (tvb_get_guint8(tvb, commhdr+6) == 0x68) {
 720              subfunction = tvb_get_guint8(tvb, commhdr+7);
 721              switch (subfunction) {
 722   
 723              case 0x02:    /* NDS Frag Packet to decode */
 724                  dissect_nds_request(next_tvb, pinfo,
 725                      nw_connection, header.sequence,
 726                      header.type, ncp_tree);
 727                  break;
 728   
 729              case 0x01:    /* NDS Ping */
 730                  dissect_ping_req(next_tvb, pinfo,
 731                      nw_connection, header.sequence,
 732                      header.type, ncp_tree);
 733                  break;
 734   
 735              default:
 736                  dissect_ncp_request(next_tvb, pinfo,
 737                      nw_connection, header.sequence,
 738                      header.type, ncp_tree);
 739                  break;
 740               }
 741          } else {
 742              dissect_ncp_request(next_tvb, pinfo, nw_connection,
 743[+]                 header.sequence, header.type, ncp_tree);
expand/collapse

dissect_ncp_request

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ncp2222.inc)expand/collapse
Show more  
 7563  dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo,
 7564                  guint32 nw_connection, guint8 sequence,
 7565                  guint16 type, proto_tree *volatile ncp_tree)
 7566  {
 7567          volatile guint8         func=0;
 7568          volatile guint8         subfunc = 0;
 7569          gboolean                requires_subfunc = FALSE;
 7570          gboolean                has_length = FALSE;
 7571          ncp_req_hash_value      *volatile request_value = NULL;
 7572          const ncp_record        *volatile ncp_rec = NULL;
 7573          conversation_t          *conversation;
 7574          ptvcursor_t             *volatile ptvc = NULL;
 7575          proto_tree              *temp_tree = NULL;
 7576          volatile gboolean       run_req_cond = FALSE;
 7577          volatile gboolean       run_info_str = FALSE;
 7578          guint32                 length_remaining;
 7579          guint32                 testvar;
 7580          volatile unsigned long  except_code;
 7581          const char              *volatile message;
 7582   
 7583   
 7584          /* Determine which ncp_record to use. */
 7585          switch (type) {
 7586                  case NCP_ALLOCATE_SLOT:
 7587                          length_remaining = tvb_length_remaining(tvb, 4);
 7588                          if (length_remaining > 4)
 7589                          {
 7590                                  testvar = tvb_get_ntohl(tvb, 4);
 7591                                  if( testvar == 0x4c495020)
 7592                                  {
 7593                                          ncp_rec = &ncplip_echo;
 7594                                  }
 7595                                  else 
 7596                                  {
 7597                                          ncp_rec = &ncp1111_request;
 7598                                          if (ncp_echo_conn) {
 7599                                                  expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Connection Request");
 7600                                          }
 7601                                  }
 7602                          }
 7603                          else 
 7604                          {
 7605                              ncp_rec = &ncp1111_request;
 7606                              if (ncp_echo_conn) {
 7607                                      expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Connection Request");
 7608                              }
 7609                          }
 7610                          break;
 7611                  case NCP_SERVICE_REQUEST:
 7612                          func = tvb_get_guint8(tvb, 6);
 7613                          requires_subfunc = ncp_requires_subfunc(func);
 7614                          has_length = ncp_has_length_parameter(func);
 7615                          if (requires_subfunc) {
 7616                                  if (has_length) {
 7617                                          subfunc = tvb_get_guint8(tvb, 9);
 7618                                  }
 7619                                  else {
 7620                                          subfunc = tvb_get_guint8(tvb, 7);
 7621                                  }
 7622                          }
 7623                          ncp_rec = ncp_record_find(func, subfunc);
 7624                          break;
 7625                  case NCP_DEALLOCATE_SLOT:
 7626                          ncp_rec = &ncp5555_request;
 7627                          if (ncp_echo_conn) {
 7628                                 expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, PI_CHAT, "Destroy Connection %u Request", nw_connection);
 7629                          }
 7630                          break;
 7631                  case NCP_BROADCAST_SLOT:
 7632                          ncp_rec = &ncpbbbb_request;
 7633                          break;
 7634                  case NCP_LIP_ECHO:
 7635                          ncp_rec = &ncplip_echo;
 7636                          break;
 7637                  default:
 7638                          ncp_rec = NULL;
 7639                          break;
 7640          }
 7641   
 7642          /* Fill in the INFO column. */
 7643[+]         if (check_col(pinfo->cinfo, COL_INFO)) {
 7644                  if (ncp_rec) {
 7645                          col_add_fstr(pinfo->cinfo, COL_INFO, "C %s", ncp_rec->name);
 7646                          if (ncp_rec->req_info_str) {
 7647                                  /* We want to add more stuff to the Info 
 7648                                     column. */
 7649                                  run_info_str = TRUE;
 7650                          }
 7651                  }
 7652                  else {
 7653                          if (requires_subfunc) {
 7654                                  col_add_fstr(pinfo->cinfo, COL_INFO,
 7655                                          "C Unknown Function %u %u (0x%02X/0x%02x)",
 7656                                          func, subfunc, func, subfunc);
 7657                                  return;
 7658                          }
 7659                          else {
 7660                                  col_add_fstr(pinfo->cinfo, COL_INFO,
 7661                                          "C Unknown Function %u (0x%02x)",
 7662                                          func, func);
 7663                                  return;
 7664                          }
 7665                  }
 7666          }
 7667          if (!pinfo->fd->flags.visited) {
 7668                  /* This is the first time we've looked at this packet.
 7669                     Keep track of the address and connection whence the request 
 7670                     came, and the address and connection to which the request 
 7671                     is being sent, so that we can match up calls with replies.
 7672                     (We don't include the sequence number, as we may want
 7673                     to have all packets over the same connection treated
 7674                     as being part of a single conversation so that we can
 7675                     let the user select that conversation to be displayed.) */
 7676                  conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
 7677                      PT_NCP, nw_connection, nw_connection, 0);
 7678   
 7679                  if (conversation == NULL) {
 7680                          /* It's not part of any conversation - create a new one. */
 7681                          conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
 7682                              PT_NCP, nw_connection, nw_connection, 0);
 7683                  }
 7684                  request_value = ncp_hash_insert(conversation, sequence, ncp_rec);
 7685                  request_value->req_frame_num = pinfo->fd->num;
 7686                  request_value->req_frame_time = pinfo->fd->abs_ts;
 7687   
 7688                  /* If this is the first time we're examining the packet,
 7689                   * check to see if this NCP type uses a "request condition".
 7690                   * If so, we have to build a proto_tree because request conditions 
 7691                   * use display filters to work, and without a proto_tree,
 7692                   * display filters can't possibly work. */
 7693                  if (ncp_rec) {
 7694                          if (ncp_rec->req_cond_indexes) {
 7695                                  run_req_cond = TRUE;
 7696                          }
 7697                  }
 7698          }
 7699   
 7700          /* If we have to handle a request condition, or have to 
 7701             add to the Info column, we need to construct a protocol
 7702             tree.  If we already have a proto_tree, then wonderful.
 7703             If we don't, we need to build one. */
 7704          if ((run_info_str || run_req_cond) && !ncp_tree) {
 7705                  proto_item *ti;
 7706   
 7707                  temp_tree = proto_tree_create_root();
 7708                  proto_tree_set_visible(temp_tree, FALSE);
 7709                  ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
 7710                  ncp_tree = proto_item_add_subtree(ti, ett_ncp);
 7711          }
 7712   
 7713          if (ncp_tree) {
 7714                  /* If the dissection throws an exception, be sure to free
 7715                   * the temporary proto_tree that was created. Because of the 
 7716                   * way the CLEANUP_PUSH macro works, we can't put it in an 'if'
 7717                   * block; it has to be in the same scope as the terminating 
 7718                   * CLEANUP_POP or CLEANUP_POP_AND_ALLOC. So, we always
 7719                   * call CLEANUP_POP and friends, but the value of temp_tree is
 7720                   * NULL if no cleanup is needed, and non-null if cleanup is needed. */
 7721                  CLEANUP_PUSH(free_proto_tree, temp_tree);
 7722   
 7723  #ifdef FAKE_TREE_IS_VISIBLE 
 7724                  PTREE_DATA(ncp_tree)->visible=1;
Show more  
Show more  




Change Warning 2839.35208 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: