Text   |  XML   |  ReML   |   Visible Warnings:

Null Pointer Dereference  at packet-smb-mailslot.c:127

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);
 15263                                  }
 15264                                  break;
 15265   
 15266                          case TRANSACTION_MAILSLOT:
 15267                                  /* This one should be safe to call 
 15268                                     even if s_tvb and sp_tvb is NULL
 15269                                  */
 15270                                  if(d_tvb){
 15271                                          dissected_trans = dissect_mailslot_smb(
 15272                                                  sp_tvb, s_tvb, d_tvb, NULL, pinfo,
 15273[+]                                                 top_tree);
expand/collapse

dissect_mailslot_smb

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-smb-mailslot.c)expand/collapse
Show more  
 84  dissect_mailslot_smb(tvbuff_t *mshdr_tvb, tvbuff_t *setup_tvb,
 85                       tvbuff_t *tvb, const char *mailslot, packet_info *pinfo,
 86                       proto_tree *parent_tree)
 87  {
 88          smb_info_t *smb_info;
 89          smb_transact_info_t *tri;
 90          int             trans_subcmd;
 91          proto_tree      *tree = NULL;
 92          proto_item      *item = NULL;
 93          guint16         opcode;
 94          int             offset = 0;
 95          int             len;
 96   
 97[+]         if (!proto_is_protocol_enabled(find_protocol_by_id(proto_smb_msp))) {
 98                  return FALSE;
 99          }
 100          pinfo->current_proto = "SMB Mailslot";
 101   
 102[+]         if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
 103                  col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMB Mailslot");
 104          }
 105   
 106          if ((tvb==NULL) || (tvb_reported_length(tvb)==0)) {
 107                  /* Interim reply */
 108                  if (check_col (pinfo->cinfo, COL_INFO)) {
 109                          col_set_str(pinfo->cinfo, COL_INFO, "Interim reply");
 110                  }
 111                  return TRUE;
 112          }
 113   
 114[+]         if (check_col(pinfo->cinfo, COL_INFO)) {
 115                  col_clear(pinfo->cinfo, COL_INFO);
 116          }
 117   
 118          smb_info = pinfo->private_data;
 119          if (smb_info->sip != NULL && smb_info->sip->extra_info_type == SMB_EI_TRI)
 120                  tri = smb_info->sip->extra_info;
 121          else 
 122                  tri = NULL;
 123   
 124          /* check which mailslot this is about */
 125          trans_subcmd=MAILSLOT_UNKNOWN;
 126          if(smb_info->request){
 127                  if(strncmp(mailslot,"BROWSE",6) == 0){
Show more  
Show more  




Change Warning 2980.35031 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: