Text   |  XML   |  ReML   |   Visible Warnings:

Null Pointer Dereference  at packet-smb-pipe.c:3661

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

dissect_transaction_response

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-smb.c)expand/collapse
Show more  
 14946  dissect_transaction_response(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, proto_tree *smb_tree _U_)
 14947  {
 14948          guint8 sc, wc;
 14949          guint16 od=0, po=0, pc=0, pd=0, dc=0, dd=0, td=0, tp=0;
 14950          smb_info_t *si;
 14951          smb_transact2_info_t *t2i = NULL;
 14952          guint16 bc;
 14953          int padcnt;
 14954          gboolean dissected_trans;
 14955          fragment_data *r_fd = NULL;
 14956          tvbuff_t *pd_tvb=NULL, *d_tvb=NULL, *p_tvb=NULL;
 14957          tvbuff_t *s_tvb=NULL, *sp_tvb=NULL;
 14958          gboolean save_fragmented;
 14959          proto_item *item;
 14960   
 14961          si = (smb_info_t *)pinfo->private_data;
 14962          DISSECTOR_ASSERT(si);
 14963   
 14964          switch(si->cmd){
 14965          case SMB_COM_TRANSACTION2:
 14966                  /* transaction2 */
 14967                  if (si->sip != NULL && si->sip->extra_info_type == SMB_EI_T2I) {
 14968                          t2i = si->sip->extra_info;
 14969                  } else 
 14970                          t2i = NULL;
 14971                  if (t2i == NULL) {
 14972                          /*
 14973                           * We didn't see the matching request, so we don't
 14974                           * know what type of transaction this is.
 14975
15027
Show [ Lines 14975 to 15027 omitted. ]
 15028                                          col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
 15029                                                  val_to_str(t2i->subcmd,
 15030                                                          trans2_cmd_vals,
 15031                                                          "<unknown (0x%02x)>"));
 15032                                  }
 15033                          }
 15034                  }
 15035                  break;
 15036          }
 15037   
 15038          WORD_COUNT;
 15039   
 15040          /* total param count, only a 16bit integer here */
 15041          tp = tvb_get_letohs(tvb, offset);
 15042          proto_tree_add_uint(tree, hf_smb_total_param_count, tvb, offset, 2, tp);
 15043          offset += 2;
 15044   
 15045          /* total data count, only a 16 bit integer here */
 15046          td = tvb_get_letohs(tvb, offset);
 15047          proto_tree_add_uint(tree, hf_smb_total_data_count, tvb, offset, 2, td);
 15048          offset += 2;
 15049
15098
Show [ Lines 15049 to 15098 omitted. ]
 15099                          s_tvb = tvb_new_subset(tvb, offset, 2*sc, 2*sc);
 15100                  }
 15101                  sp_tvb = tvb_new_subset(tvb, offset, -1, -1);
 15102          } else {
 15103                  s_tvb = NULL;
 15104                  sp_tvb=NULL;
 15105          }
 15106          offset += 2*sc;
 15107   
 15108   
 15109[+]         BYTE_COUNT;
 15110   
 15111   
 15112          /* reassembly of SMB Transaction data payload.
 15113             In this section we do reassembly of both the data and parameters 
 15114             blocks of the SMB transaction command.
 15115          */
 15116          save_fragmented = pinfo->fragmented;
 15117          /* do we need reassembly? */
 15118          if( (td!=dc) || (tp!=pc) ){
 15119                  /* oh yeah, either data or parameter section needs
 15120                     reassembly
 15121                  */
 15122                  pinfo->fragmented = TRUE;
 15123                  if(smb_trans_reassembly){
 15124                          /* ...and we were told to do reassembly */
 15125                          if(pc && (tvb_length_remaining(tvb, po)>=pc) ){
 15126                                  r_fd = smb_trans_defragment(tree, pinfo, tvb,
 15127                                                               po, pc, pd, td+tp);
 15128   
 15129                          }
 15130                          if((r_fd==NULL) && dc && (tvb_length_remaining(tvb, od)>=dc) ){
 15131                                  r_fd = smb_trans_defragment(tree, pinfo, tvb,
 15132                                                               od, dc, dd+tp, td+tp);
 15133                          }
 15134                  }
 15135          }
 15136   
 15137          /* if we got a reassembled fd structure from the reassembly routine we must 
 15138             create pd_tvb from it 
 15139          */
 15140          if(r_fd){
 15141          proto_item *frag_tree_item;
 15142   
 15143                  pd_tvb = tvb_new_real_data(r_fd->data, r_fd->datalen,
 15144                                               r_fd->datalen);
 15145                  tvb_set_child_real_data_tvbuff(tvb, pd_tvb);
 15146                  add_new_data_source(pinfo, pd_tvb, "Reassembled SMB");
 15147                  show_fragment_tree(r_fd, &smb_frag_items, tree, pinfo, pd_tvb, &frag_tree_item);
 15148          }
 15149   
 15150   
 15151          if(pd_tvb){
 15152                  /* OK we have reassembled data, extract d_tvb and p_tvb from it */
 15153                  if(tp){
 15154                          p_tvb = tvb_new_subset(pd_tvb, 0, tp, tp);
 15155                  }
 15156                  if(td){
 15157                          d_tvb = tvb_new_subset(pd_tvb, tp, td, td);
 15158                  }
 15159          } else {
 15160                  /* It was not reassembled. Do as best as we can.
 15161                   * in this case we always try to dissect the stuff if 
 15162                   * data and param displacement is 0. i.e. for the first 
 15163                   * (and maybe only) packet.
 15164                   */
 15165                  if( (pd==0) && (dd==0) ){
 15166                          int min;
 15167                          int reported_min;
 15168                          min = MIN(pc,tvb_length_remaining(tvb,po));
 15169                          reported_min = MIN(pc,tvb_reported_length_remaining(tvb,po));
 15170                          if(min && reported_min) {
 15171                                  p_tvb = tvb_new_subset(tvb, po, min, reported_min);
 15172                          }
 15173                          min = MIN(dc,tvb_length_remaining(tvb,od));
 15174                          reported_min = MIN(dc,tvb_reported_length_remaining(tvb,od));
 15175                          if(min && reported_min) {
 15176                                  d_tvb = tvb_new_subset(tvb, od, min, reported_min);
 15177                          }
 15178                          /*
 15179                           * A tvbuff containing the parameters 
 15180                           * and the data.
 15181                           * XXX - check pc and dc as well?
 15182                           */
 15183                          if (tvb_length_remaining(tvb, po)){
 15184[+]                                 pd_tvb = tvb_new_subset(tvb, po, -1, -1);
 15185                          }
 15186                  }
 15187          }
 15188   
 15189   
 15190   
 15191          /* parameters */
 15192          if(po>offset){
 15193                  /* We have some padding bytes.
 15194                  */
 15195                  padcnt = po-offset;
 15196                  if (padcnt > bc)
 15197                          padcnt = bc;
 15198                  proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, TRUE);
 15199                  COUNT_BYTES(padcnt);
 15200          }
 15201          if(si->cmd==SMB_COM_TRANSACTION2 && p_tvb){
 15202                  /* TRANSACTION2 parameters*/
 15203                  dissect_transaction2_response_parameters(p_tvb, pinfo, tree);
 15204          }
 15205          COUNT_BYTES(pc);
 15206   
 15207   
 15208          /* data */
 15209          if(od>offset){
 15210                  /* We have some initial padding bytes.
 15211                  */
 15212                  padcnt = od-offset;
 15213                  if (padcnt > bc)
 15214                          padcnt = bc;
 15215                  proto_tree_add_item(tree, hf_smb_padding, tvb, offset, padcnt, TRUE);
 15216                  COUNT_BYTES(padcnt);
 15217          }
 15218          /*
 15219           * If the data count is bigger than the count of bytes 
 15220           * remaining, clamp it so that the count of bytes remaining 
 15221           * doesn't go negative.
 15222           */
 15223          if (dc > bc)
 15224                  dc = bc;
 15225          COUNT_BYTES(dc);
 15226   
 15227   
 15228   
 15229          /* from now on, everything is in separate tvbuffs so we dont count 
 15230             the bytes with COUNT_BYTES any more.
 15231             neither do we reference offset any more (which by now points to the 
 15232             first byte AFTER this PDU */
 15233   
 15234   
 15235          if(si->cmd==SMB_COM_TRANSACTION2 && d_tvb){
 15236                  /* TRANSACTION2 parameters*/
 15237                  dissect_transaction2_response_data(d_tvb, pinfo, tree);
 15238          }
 15239   
 15240   
 15241          if(si->cmd==SMB_COM_TRANSACTION){
 15242                  smb_transact_info_t *tri;
 15243   
 15244                  dissected_trans = FALSE;
 15245                  if (si->sip != NULL && si->sip->extra_info_type == SMB_EI_TRI)
 15246                          tri = si->sip->extra_info;
 15247                  else 
 15248                          tri = NULL;
 15249                  if (tri != NULL) {
 15250                          switch(tri->subcmd){
 15251   
 15252                          case TRANSACTION_PIPE:
 15253                                  /* This function is safe to call for 
 15254                                     s_tvb==sp_tvb==NULL, i.e. if we don't
 15255                                     know them at this point.
 15256                                     It's also safe to call if "p_tvb"
 15257                                     or "d_tvb" are null.
 15258                                  */
 15259                                  if( pd_tvb) {
 15260                                          dissected_trans = dissect_pipe_smb(
 15261                                                  sp_tvb, s_tvb, pd_tvb, p_tvb,
 15262[+]                                                 d_tvb, NULL, pinfo, top_tree);
expand/collapse

dissect_pipe_smb

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-smb-pipe.c)expand/collapse
Show more  
 3518  dissect_pipe_smb(tvbuff_t *sp_tvb, tvbuff_t *s_tvb, tvbuff_t *pd_tvb,
 3519                   tvbuff_t *p_tvb, tvbuff_t *d_tvb, const char *pipe,
 3520                   packet_info *pinfo, proto_tree *tree)
 3521  {
 3522          smb_info_t *smb_info;
 3523          smb_transact_info_t *tri;
 3524          guint sp_len;
 3525          proto_item *pipe_item = NULL;
 3526          proto_tree *pipe_tree = NULL;
 3527          int offset;
 3528          int trans_subcmd=0;
 3529          int function;
 3530          int fid = -1;
 3531          guint16 info_level;
 3532   
 3533[+]         if (!proto_is_protocol_enabled(find_protocol_by_id(proto_smb_pipe)))
 3534                  return FALSE;
 3535          pinfo->current_proto = "SMB Pipe";
 3536   
 3537          smb_info = pinfo->private_data;
 3538   
 3539          /*
 3540           * Set the columns.
 3541           */
 3542          if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
 3543                  col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMB Pipe");
 3544          }
 3545          if (check_col(pinfo->cinfo, COL_INFO)) {
 3546                  col_set_str(pinfo->cinfo, COL_INFO,
 3547                      smb_info->request ? "Request" : "Response");
 3548          }
 3549   
 3550          if (smb_info->sip != NULL && smb_info->sip->extra_info_type == SMB_EI_TRI)
 3551                  tri = smb_info->sip->extra_info;
 3552          else 
 3553                  tri = NULL;
 3554   
 3555          /*
 3556           * Set up a subtree for the pipe protocol.  (It might not contain 
 3557           * anything.)
 3558           */
 3559          if (sp_tvb != NULL)
 3560                  sp_len = tvb_length(sp_tvb);
 3561          else 
 3562                  sp_len = 0;
 3563          if (tree) {
 3564                  pipe_item = proto_tree_add_item(tree, proto_smb_pipe,
 3565                      sp_tvb, 0, sp_len, FALSE);
 3566                  pipe_tree = proto_item_add_subtree(pipe_item, ett_smb_pipe);
 3567          }
 3568          offset = 0;
 3569   
 3570          /*
 3571           * Do we have any setup words at all?
 3572           */
 3573          if (s_tvb != NULL && tvb_length(s_tvb) != 0) {
 3574                  /*
 3575                   * Yes.  The first of them is the function.
 3576                   */
 3577                  function = tvb_get_letohs(s_tvb, offset);
 3578                  proto_tree_add_uint(pipe_tree, hf_pipe_function, s_tvb,
 3579                      offset, 2, function);
 3580                  offset += 2;
 3581                  if (check_col(pinfo->cinfo, COL_INFO)) {
 3582                          col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
 3583                              val_to_str(function, functions, "Unknown function (0x%04x)"),
 3584
3616
Show [ Lines 3584 to 3616 omitted. ]
 3617                          break;
 3618   
 3619                  default:
 3620                          /*
 3621                           * It's something unknown.
 3622                           * XXX - put it into the tree?
 3623                           */
 3624                          break;
 3625                  }
 3626                  offset += 2;
 3627          } else {
 3628                  /*
 3629                   * This is either a response or a pipe transaction with
 3630                   * no setup information.
 3631                   *
 3632                   * In the former case, we can get that information from
 3633                   * the matching request, if we saw it.
 3634                   *
 3635                   * In the latter case, there is no function or FID.
 3636                   */
 3637                  if (tri != NULL && tri->function != -1) {
 3638                          function = tri->function;
 3639                          proto_tree_add_uint(pipe_tree, hf_pipe_function, NULL,
 3640                              0, 0, function);
 3641                          if (check_col(pinfo->cinfo, COL_INFO)) {
 3642                                  col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
 3643                                      val_to_str(function, functions, "Unknown function (0x%04x)"),
 3644                                      smb_info->request ? "Request" : "Response");
 3645                          }
 3646                          fid = tri->fid;
 3647                          if (fid != -1)
 3648                                  dissect_smb_fid(d_tvb, pinfo, pipe_tree, 0, 0, (guint16) fid, FALSE, FALSE, TRUE);
 3649                  } else {
 3650                          function = -1;
 3651                          fid = -1;
 3652                  }
 3653          }
 3654   
 3655          /*
 3656           * XXX - put the byte count and the pipe name into the tree as well;
 3657           * that requires us to fetch a possibly-Unicode string.
 3658           */
 3659   
 3660          if(smb_info->request){
 3661                  if(strncmp(pipe,"LANMAN",6) == 0){
Show more  
Show more  




Change Warning 2981.35032 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: