Text   |  XML   |  ReML   |   Visible Warnings:

Cast Alters Value  at packet-gssapi.c:399

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

dissect_gssapi_work

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-gssapi.c)expand/collapse
Show more  
 172  dissect_gssapi_work(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 173      gboolean is_verifier)
 174  {
 175          proto_item *volatile item;
 176          proto_tree *volatile subtree;
 177          volatile int return_offset = 0;
 178          gssapi_conv_info_t *volatile gss_info;
 179          gssapi_oid_value *oidvalue;
 180          dissector_handle_t handle;
 181          conversation_t *conversation;
 182          tvbuff_t *oid_tvb;
 183          int len, start_offset, oid_start_offset;
 184          volatile int offset;
 185          gint8 class;
 186          gboolean pc, ind_field;
 187          gint32 tag;
 188          guint32 len1;
 189          const char *oid;
 190          fragment_data *fd_head=NULL;
 191          gssapi_frag_info_t *fi;
 192          tvbuff_t *volatile gss_tvb=NULL;
 193          asn1_ctx_t asn1_ctx;
 194   
 195          start_offset=0;
 196          offset=0;
 197          asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
 198          /*
 199           * We don't know whether the data is encrypted, so say it's
 200           * not, for now.  The subdissector must set gssapi_data_encrypted
 201           * if it is.
 202           */
 203          pinfo->gssapi_data_encrypted = FALSE;
 204   
 205   
 206          /*
 207           * We need a conversation for later
 208           */
 209          conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
 210                                           pinfo->ptype, pinfo->srcport,
 211                                           pinfo->destport, 0);
 212          if(!conversation){
 213                  conversation = conversation_new(pinfo->fd->num, &pinfo->src,
 214                                            &pinfo->dst,  
 215                                            pinfo->ptype,  
 216                                            pinfo->srcport,  
 217                                            pinfo->destport, 0);
 218          }
 219          gss_info = conversation_get_proto_data(conversation, proto_gssapi);
 220          if (!gss_info) {
 221                  gss_info = se_alloc(sizeof(gssapi_conv_info_t));
 222                  gss_info->oid=NULL;
 223                  gss_info->do_reassembly=FALSE;
 224                  gss_info->frags=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "gssapi_frags");
 225   
 226                  conversation_add_proto_data(conversation, proto_gssapi, gss_info);
 227          }
 228   
 229          item = proto_tree_add_item(
 230                  tree, proto_gssapi, tvb, offset, -1, FALSE);
 231   
 232          subtree = proto_item_add_subtree(item, ett_gssapi);
 233   
 234          /*
 235           * Catch the ReportedBoundsError exception; the stuff we've been 
 236           * handed doesn't necessarily run to the end of the packet, it's
 237           * an item inside a packet, so if it happens to be malformed (or
 238           * we, or a dissector we call, has a bug), so that an exception
 239           * is thrown, we want to report the error, but return and let
 240           * our caller dissect the rest of the packet.
 241           *
 242           * If it gets a BoundsError, we can stop, as there's nothing more
 243           * in the packet after our blob to see, so we just re-throw the 
 244           * exception.
 245           */
 246          TRY {
 247                  gss_tvb=tvb;
 248   
 249   
 250                  /* First of all, if its the first time we see this packet 
 251                   * then check whether we are in the middle of reassembly or not
 252                   */
 253                  if( (!pinfo->fd->flags.visited)
 254                  &&  (gss_info->do_reassembly)
 255                  &&  (gssapi_reassembly) ){
 256                          fi=se_tree_lookup32(gss_info->frags, gss_info->first_frame);
 257                          if(!fi){
 258                                  goto done;
 259                          }
 260                          se_tree_insert32(gss_info->frags, pinfo->fd->num, fi);
 261                          fd_head=fragment_add(tvb, 0, pinfo, fi->first_frame,
 262                                  gssapi_fragment_table, gss_info->frag_offset,
 263                                  tvb_length(tvb), TRUE);
 264                          gss_info->frag_offset+=tvb_length(tvb);
 265   
 266                          /* we need more fragments */
 267                          if(!fd_head){
 268                                  goto done;
 269                          }
 270   
 271                          /* this blob is now fully reassembled */
 272                          gss_info->do_reassembly=FALSE;
 273                          fi->reassembled_in=pinfo->fd->num;
 274   
 275                          gss_tvb=tvb_new_child_real_data(tvb, fd_head->data, fd_head->datalen, fd_head->datalen);
 276                          add_new_data_source(pinfo, gss_tvb, "Reassembled GSSAPI");
 277                  }
 278                  /* We have seen this packet before.
 279                   * Is this blob part of reassembly or a normal blob ?
 280                   */
 281                  if( (pinfo->fd->flags.visited)
 282                  &&  (gssapi_reassembly) ){      
 283                          fi=se_tree_lookup32(gss_info->frags, pinfo->fd->num);
 284                          if(fi){
 285                                  fd_head=fragment_get(pinfo, fi->first_frame, gssapi_fragment_table);
 286                                  if(fd_head && (fd_head->flags&FD_DEFRAGMENTED)){
 287                                          if(pinfo->fd->num==fi->reassembled_in){
 288                                                  proto_item *frag_tree_item;
 289                                                  gss_tvb=tvb_new_child_real_data(tvb, fd_head->data, fd_head->datalen, fd_head->datalen);
 290                                                  add_new_data_source(pinfo, gss_tvb, "Reassembled GSSAPI");
 291                                                  show_fragment_tree(fd_head, &gssapi_frag_items, tree, pinfo, tvb, &frag_tree_item);
 292                                          } else {
 293                                                  proto_item *it;
 294                                                  it=proto_tree_add_uint(tree, hf_gssapi_reassembled_in, tvb, 0, 0, fi->reassembled_in);
 295                                                  PROTO_ITEM_SET_GENERATED(it);
 296                                                  goto done;
 297                                          }
 298                                  }
 299                          }
 300                  }
 301   
 302                  /* Read header */
 303[+]                 offset = get_ber_identifier(gss_tvb, offset, &class, &pc, &tag);
 304                  offset = get_ber_length(gss_tvb, offset, &len1, &ind_field);
 305   
 306   
 307                  if (!(class == BER_CLASS_APP && pc && tag == 0)) {
 308                    /* It could be NTLMSSP, with no OID.  This can happen  
 309                       for anything that microsoft calls 'Negotiate' or GSS-SPNEGO */
 310                    if ((tvb_length_remaining(gss_tvb, start_offset)>7) && (tvb_strneql(gss_tvb, start_offset, "NTLMSSP", 7) == 0)) {
 311                      return_offset = call_dissector(ntlmssp_handle,
 312                                                     tvb_new_subset(gss_tvb, start_offset, -1, -1),
 313                                                     pinfo, subtree);
 314                      goto done;
 315                    }
 316   
 317                    /* Maybe it's new GSSKRB5 CFX Wrapping */
 318
369
Show [ Lines 318 to 369 omitted. ]
 370                      len = call_dissector(handle, oid_tvb_local, pinfo, subtree);
 371                      if (len == 0)
 372                          return_offset = tvb_length(gss_tvb);
 373                      else 
 374                          return_offset = start_offset + len;
 375                      goto done; /* We are finished here */
 376                    }
 377                  }
 378   
 379                  /* Read oid */
 380                  oid_start_offset=offset;
 381                  offset=dissect_ber_object_identifier_str(FALSE, &asn1_ctx, subtree, gss_tvb, offset, hf_gssapi_oid, &oid);
 382[+]                 oidvalue = gssapi_lookup_oid_str(oid);
 383   
 384   
 385                  /* Check if we need reassembly of this blob.
 386                   * Only try reassembly for OIDs we recognize 
 387                   * and when we have the entire tvb 
 388                   *
 389                   * SMB will sometimes split one large GSSAPI blob
 390                   * across multiple SMB/SessionSetup commands.
 391                   * While we should look at the uid returned in the response 
 392                   * to the first SessionSetup and use that as a key
 393                   * instead for simplicity we assume there will not be several
 394                   * such authentication at once on a single tcp session 
 395                   */
 396                  if( (!pinfo->fd->flags.visited)
 397                  &&  (oidvalue)
 398                  &&  (tvb_length(gss_tvb)==tvb_reported_length(gss_tvb))
 399[+]                 &&  (len1>(guint32)tvb_length_remaining(gss_tvb, oid_start_offset))
Show more  




Change Warning 2619.33864 : Cast Alters Value

Priority:
State:
Finding:
Owner:
Note: