Text   |  XML   |  ReML   |   Visible Warnings:

Null Pointer Dereference  at packet-ncp2222.inc:7849

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

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
7623
Show [ Lines 7596 to 7623 omitted. ]
 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
7693
Show [ Lines 7678 to 7693 omitted. ]
 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;
 7725  #endif
 7726   
 7727                  /* Before the dissection, if we're saving data for a request 
 7728                   * condition, we have to prime the proto tree using the 
 7729                   * dfilter information */
 7730                  if (run_req_cond) {
 7731                          const int       *needed;
 7732                          dfilter_t       *dfilter;
 7733   
 7734                          needed = ncp_rec->req_cond_indexes;
 7735   
 7736                          while (*needed != -1) {
 7737                                  dfilter = req_conds[*needed].dfilter;
 7738                                  /* Prime the proto_tree with "interesting fields". */
 7739                                  dfilter_prime_proto_tree(dfilter, ncp_tree);
 7740                                  needed++;
 7741                          }
 7742                  }
 7743   
 7744                  /* Before the dissection, if we need a field for the info_str,
 7745                   * prime the tree. */
 7746                  if (run_info_str) {
 7747                          proto_tree_prime_hfid(ncp_tree, *ncp_rec->req_info_str->hf_ptr);
 7748                  }
 7749   
 7750                  switch (type) {
 7751                          case NCP_BROADCAST_SLOT:
 7752                                  ; /* nothing */
 7753                                  break;
 7754   
 7755                          case NCP_SERVICE_REQUEST:
 7756                                  proto_tree_add_uint_format(ncp_tree, hf_ncp_func, tvb, 6, 1,
 7757                                          func, "Function: %u (0x%02X), %s",
 7758                                          func, func, ncp_rec ? ncp_rec->name : "Unknown");
 7759                                  break;
 7760   
 7761                          default:
 7762                                  ; /* nothing */
 7763                                  break;
 7764                  }
 7765                  if (request_value) {
 7766                          request_value->length = 0;
 7767                  }
 7768                  if (requires_subfunc) {
 7769                          if (has_length) {
 7770                                  if (request_value && func==123) {
 7771                                          request_value->length = tvb_get_ntohs(tvb, 7);
 7772                                  }
 7773                                  proto_tree_add_item(ncp_tree, hf_ncp_length, tvb, 7,
 7774                                          2, FALSE);
 7775                                  proto_tree_add_uint_format(ncp_tree, hf_ncp_subfunc, tvb, 9, 1,
 7776                                          subfunc, "SubFunction: %u (0x%02x)",
 7777                                          subfunc, subfunc);
 7778                                  ptvc = ptvcursor_new(ncp_tree, tvb, 10);
 7779                           }
 7780                          else {
 7781                                  proto_tree_add_uint_format(ncp_tree, hf_ncp_subfunc, tvb, 7, 1,
 7782                                          subfunc, "SubFunction: %u (0x%02x)",
 7783                                          subfunc, subfunc);
 7784                                  ptvc = ptvcursor_new(ncp_tree, tvb, 8);
 7785                          }
 7786                  }
 7787                  else {
 7788                          ptvc = ptvcursor_new(ncp_tree, tvb, 7);
 7789                  }
 7790   
 7791          /* The group is not part of the packet, but it's useful 
 7792                   * information to display anyway. Put it in the tree for filtering and tap use*/
 7793                  if (ncp_rec) {
 7794                          proto_tree_add_uint_format(ncp_tree, hf_ncp_group, tvb, 0, 0, ncp_rec->group, "Group: %s", ncp_groups[ncp_rec->group]);
 7795                  }
 7796   
 7797                  except_code = 0;
 7798                  message = NULL;
 7799                  if (ncp_rec && ncp_rec->request_ptvc) {
 7800                          clear_repeat_vars();
 7801                          /*
 7802                           * We need to remember the results even if we 
 7803                           * throw an exception dissecting this request,
 7804                           * so that we can properly dissect the reply.
 7805                           * We catch any exceptions thrown when
 7806                           * dissecting the request, and re-throw them 
 7807                           * after saving the results of any conditional 
 7808                           * tests.
 7809                           */
 7810                          TRY {
 7811                                  process_ptvc_record(ptvc, ncp_rec->request_ptvc, NULL, TRUE, ncp_rec);
 7812                          } CATCH_ALL {
 7813                                  except_code = EXCEPT_CODE;
 7814                                  message = GET_MESSAGE;
 7815                          }
 7816                          ENDTRY;
 7817                  }
 7818                  ptvcursor_free(ptvc);
 7819                  /* SecretStore packets are dessected in packet-ncp-sss.c */
 7820                  if (func == 0x5c && ncp_tree) {
 7821                          dissect_sss_request(tvb, pinfo, ncp_tree, request_value);
 7822                  }
 7823                  /* NMAS packets are dessected in packet-ncp-nmas.c */
 7824                  if (func == 0x5e && ncp_tree) {
 7825                          dissect_nmas_request(tvb, pinfo, ncp_tree, request_value);
 7826                  }
 7827   
 7828                  /* Now that the dissection is done, do we need to run 
 7829                   * some display filters on the resulting tree in order 
 7830                   * to save results for "request conditions" ? */
 7831                  if (run_req_cond) {
 7832                          const int       *needed;
 7833                          gboolean        *results;
 7834                          dfilter_t       *dfilter;
 7835   
 7836                          results = g_new0(gboolean, NUM_REQ_CONDS);
 7837                          needed = ncp_rec->req_cond_indexes;
 7838   
 7839                          while (*needed != -1) {
 7840                                  /* ncp_tree is not a root proto_tree, but 
 7841                                   * dfilters will still work on it. */
 7842                                  dfilter = req_conds[*needed].dfilter;
 7843                                  results[*needed] = dfilter_apply(dfilter, ncp_tree);
 7844                                  needed++;
 7845                          }
 7846   
 7847                          /* Save the results so the reply packet dissection
 7848                           * get to them. */
 7849                          request_value->req_cond_results = results;
Show more  




Change Warning 2835.34806 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: