Text   |  XML   |  ReML   |   Visible Warnings:

Null Test After Dereference  at packet-beep.c:974

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

dissect_beep

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-beep.c)expand/collapse
Show more  
 830  dissect_beep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 831  {
 832    int offset;
 833    struct beep_proto_data  *beep_frame_data = NULL;
 834    proto_tree              *beep_tree = NULL, *ti = NULL;
 835    conversation_t          *conversation = NULL;
 836    struct beep_request_key request_key, *new_request_key;
 837    struct beep_request_val *request_val = NULL;
 838   
 839    offset = 0;
 840   
 841    /* If we have per frame data, use that, else, we must have lost the per-
 842     * frame data, and we have to do a full dissect pass again.
 843     *
 844     * The per-frame data tells us how much of this frame is left over from a 
 845     * previous frame, so we dissect it as payload and then try to dissect the
 846     * rest.
 847     *
 848     * We use the conversation to build up info on the first pass over the
 849     * packets of type BEEP, and record anything that is needed if the user 
 850     * does random dissects of packets in per packet data.
 851     *
 852     * Once we have per-packet data, we don't need the conversation stuff
 853     * anymore, but if per-packet data and conversation stuff gets deleted, as 
 854     * it does under some circumstances when a rescan is done, it all gets 
 855     * rebuilt.
 856     */
 857   
 858    /* Find out what conversation this packet is part of ... but only
 859     * if we have no information on this packet, so find the per-frame
 860     * info first.
 861     */
 862   
 863    beep_frame_data = p_get_proto_data(pinfo->fd, proto_beep);
 864   
 865    if (!beep_frame_data) {
 866   
 867      conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
 868                                         pinfo->srcport, pinfo->destport, 0);
 869      if (conversation == NULL) { /* No conversation, create one */
 870          conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
 871                                          pinfo->srcport, pinfo->destport, 0);
 872   
 873        }
 874   
 875        /*
 876         * Check for and insert an entry in the request table if does not exist
 877         */
 878        request_key.conversation = conversation->index;
 879   
 880        request_val = (struct beep_request_val *)g_hash_table_lookup(beep_request_hash, &request_key);
 881   
 882        if (!request_val) { /* Create one */
 883   
 884          new_request_key = se_alloc(sizeof(struct beep_request_key));
 885          new_request_key->conversation = conversation->index;
 886   
 887          request_val = se_alloc(sizeof(struct beep_request_val));
 888          request_val->processed = 0;
 889          request_val->size = 0;
 890   
 891          g_hash_table_insert(beep_request_hash, new_request_key, request_val);
 892   
 893        }
 894      }
 895   
 896    if (check_col(pinfo->cinfo, COL_PROTOCOL))
 897      col_set_str(pinfo->cinfo, COL_PROTOCOL, "BEEP");
 898   
 899    if (check_col(pinfo->cinfo, COL_INFO)) {  /* Check the type ... */
 900   
 901      /* "tvb_format_text()" is passed a value that won't go past the end
 902       * of the packet, so it won't throw an exception. */
 903      col_add_str(pinfo->cinfo, COL_INFO, tvb_format_text(tvb, offset, tvb_length_remaining(tvb, offset)));
 904   
 905    }
 906   
 907    /* Here, we parse the message so we can retrieve the info we need, which 
 908     * is that there is some payload left from a previous segment on the 
 909     * front of this segment ... This all depends on TCP segments not getting
 910     * out of order ...
 911     *
 912     * As a huge kludge, we push the checking for the tree down into the code 
 913     * and process as if we were given a tree but not call the routines that 
 914     * adorn the protocol tree if they were NULL.
 915     */
 916   
 917    if (tree) {  /* Build the tree info ... */
 918   
 919      ti = proto_tree_add_item(tree, proto_beep, tvb, offset, -1, FALSE);
 920   
 921      beep_tree = proto_item_add_subtree(ti, ett_beep);
 922   
 923    }
 924   
 925    /* Check the per-frame data and the conversation for any left-over
 926     * payload from the previous frame 
 927     *
 928     * We check that per-frame data exists first, and if so, use it,
 929     * else we use the conversation data.
 930     *
 931     * We create per-frame data here as well, but we must ensure we create it 
 932     * after we have done the check for per-frame or conversation data.
 933     *
 934     * We also depend on the first frame in a group having a pl_size of 0.
 935     */
 936   
 937    if (beep_frame_data && beep_frame_data->pl_left > 0) {
 938   
 939      int pl_left = beep_frame_data->pl_left;
 940   
 941      pl_left = MIN(pl_left, tvb_length_remaining(tvb, offset));
 942   
 943      /* Add the payload bit, only if we have a tree */
 944      if (tree) {
 945        proto_tree_add_text(beep_tree, tvb, offset, pl_left, "Payload: %s",
 946                            tvb_format_text(tvb, offset, pl_left));
 947      }
 948      offset += pl_left;
 949    }
 950    else if (request_val && request_val->size > 0) {
 951   
 952      int pl_left = request_val->size;
 953   
 954      request_val->size = 0;
 955   
 956      /* We create the frame data here for this case, and 
 957       * elsewhere for other frames
 958       */
 959   
 960      beep_frame_data = se_alloc(sizeof(struct beep_proto_data));
 961   
 962      beep_frame_data->pl_left = pl_left;
 963      beep_frame_data->pl_size = 0;
 964      beep_frame_data->mime_hdr = 0;
 965   
 966      p_add_proto_data(pinfo->fd, proto_beep, beep_frame_data);
 967   
 968    }
 969   
 970    /* Set up the per-frame data here if not already done so 
 971     * This _must_ come after the checks above ...
 972     */
 973   
 974    if (beep_frame_data == NULL) {
 975   
 976      beep_frame_data = se_alloc(sizeof(struct beep_proto_data));
 977   
 978      beep_frame_data->pl_left = 0;
 979      beep_frame_data->pl_size = 0;
 980      beep_frame_data->mime_hdr = 0;
 981   
 982      p_add_proto_data(pinfo->fd, proto_beep, beep_frame_data);
 983   
 984    }
 985   
 986    if (tvb_length_remaining(tvb, offset) > 0) {
 987   
 988      offset += dissect_beep_tree(tvb, offset, pinfo, beep_tree, request_val, beep_frame_data);
 989   
 990    }
 991   
 992  }
Show more  




Change Warning 12382.32285 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: