Text   |  XML   |  ReML   |   Visible Warnings:

Cast Alters Value  at proto.c:2892

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

dissect_ppi

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ppi.c)expand/collapse
Show more  
 731  dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 732  {
 733      proto_tree *ppi_tree = NULL, *ppi_flags_tree = NULL, *seg_tree = NULL, *ampdu_tree = NULL;
 734      proto_tree *agg_tree = NULL;
 735      proto_item *ti = NULL;
 736      tvbuff_t *next_tvb;
 737      int offset = 0;
 738      guint version, flags;
 739      gint tot_len, data_len;
 740      guint data_type;
 741      guint32 dlt;
 742      guint32 n_ext_flags = 0;
 743      guint32 ampdu_id = 0;
 744      fragment_data *fd_head = NULL, *ft_fdh = NULL;
 745      gint len_remain, pad_len = 0, ampdu_len = 0;
 746      gint mpdu_count = 0;
 747      gchar mpdu_str[12]; /* "MPDU #xxxxx" */
 748      gboolean first_mpdu = TRUE;
 749      guint last_frame = 0;
 750      gboolean is_ht = FALSE;
 751   
 752[+]     if(check_col(pinfo->cinfo, COL_PROTOCOL))
 753          col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPI");
 754      if(check_col(pinfo->cinfo, COL_INFO))
 755          col_clear(pinfo->cinfo, COL_INFO);
 756   
 757      version = tvb_get_guint8(tvb, offset);
 758      flags = tvb_get_guint8(tvb, offset + 1);
 759   
 760      tot_len = tvb_get_letohs(tvb, offset+2);
 761      dlt = tvb_get_letohl(tvb, offset+4);
 762   
 763[+]     if(check_col(pinfo->cinfo, COL_INFO))
 764          col_add_fstr(pinfo->cinfo, COL_INFO, "PPI version %u, %u bytes",
 765                  version, tot_len);
 766   
 767      /* Dissect the packet */
 768      if (tree) {
 769          ti = proto_tree_add_protocol_format(tree, proto_ppi,
 770              tvb, 0, tot_len, "PPI version %u, %u bytes", version, tot_len);
 771          ppi_tree = proto_item_add_subtree(ti, ett_ppi_pph);
 772          proto_tree_add_item(ppi_tree, hf_ppi_head_version,
 773              tvb, offset, 1, TRUE);
 774   
 775          ti = proto_tree_add_item(ppi_tree, hf_ppi_head_flags,
 776              tvb, offset + 1, 1, TRUE);
 777          ppi_flags_tree = proto_item_add_subtree(ti, ett_ppi_flags);
 778          proto_tree_add_item(ppi_flags_tree, hf_ppi_head_flag_alignment,
 779              tvb, offset + 1, 1, TRUE);
 780          proto_tree_add_item(ppi_flags_tree, hf_ppi_head_flag_reserved,
 781              tvb, offset + 1, 1, TRUE);
 782   
 783          ti = proto_tree_add_item(ppi_tree, hf_ppi_head_len,
 784              tvb, offset + 2, 2, TRUE);
 785          ti = proto_tree_add_item(ppi_tree, hf_ppi_head_dlt,
 786              tvb, offset + 4, 4, TRUE);
 787      }
 788   
 789      tot_len -= PPI_V0_HEADER_LEN;
 790      offset += 8;
 791   
 792      while (tot_len > 0) {
 793          data_type = tvb_get_letohs(tvb, offset);
 794          data_len = tvb_get_letohs(tvb, offset + 2) + 4;
 795          tot_len -= data_len;
 796   
 797          switch (data_type) {
 798              case PPI_80211_COMMON:
 799                  dissect_80211_common(tvb, pinfo, ppi_tree, offset, data_len);
 800                  break;
 801   
 802              case PPI_80211N_MAC:
 803                  dissect_80211n_mac(tvb, pinfo, ppi_tree, offset, data_len,
 804                      TRUE, &n_ext_flags, &ampdu_id);
 805                  is_ht = TRUE;
 806                  break;
 807   
 808              case PPI_80211N_MAC_PHY:
 809                  dissect_80211n_mac_phy(tvb, pinfo, ppi_tree, offset,
 810                      data_len, &n_ext_flags, &ampdu_id);
 811                  is_ht = TRUE;
 812                  break;
 813   
 814              case PPI_SPECTRUM_MAP:
 815                  ADD_BASIC_TAG(hf_spectrum_map);
 816                  break;
 817   
 818              case PPI_PROCESS_INFO:
 819                  ADD_BASIC_TAG(hf_process_info);
 820                  break;
 821   
 822              case PPI_CAPTURE_INFO:
 823                  ADD_BASIC_TAG(hf_capture_info);
 824                  break;
 825   
 826              case PPI_AGGREGATION_EXTENSION:
 827                  dissect_aggregation_extension(tvb, pinfo, ppi_tree, offset, data_len);
 828                  break;
 829   
 830              case PPI_8023_EXTENSION:
 831                  dissect_8023_extension(tvb, pinfo, ppi_tree, offset, data_len);
 832                  break;
 833   
 834              default:
 835                  if (tree)
 836                      proto_tree_add_text(ppi_tree, tvb, offset, data_len,
 837                          "%s (%u bytes)", val_to_str(data_type, (value_string *)&vs_ppi_field_type, "Reserved"), data_len);
 838          }
 839   
 840          offset += data_len;
 841          if (IS_PPI_FLAG_ALIGN(flags)){
 842              offset += PADDING4(offset);
 843          }
 844      }
 845   
 846      if (ppi_ampdu_reassemble && DOT11N_IS_AGGREGATE(n_ext_flags)) {
 847          len_remain = tvb_length_remaining(tvb, offset);
 848          if (DOT11N_MORE_AGGREGATES(n_ext_flags)) {
 849              pad_len = PADDING4(len_remain);
 850          }
 851          pinfo->fragmented = TRUE;
 852   
 853          /* Make sure we aren't going to go past AGGREGATE_MAX 
 854           * and caclulate our full A-MPDU length */
 855          fd_head = fragment_get(pinfo, ampdu_id, ampdu_fragment_table);
 856          while (fd_head) {
 857              ampdu_len += fd_head->len + PADDING4(fd_head->len) + 4;
 858              fd_head = fd_head->next;
 859          }
 860          if (ampdu_len > AGGREGATE_MAX) {
 861              if (tree) {
 862                  proto_tree_add_text(ppi_tree, tvb, offset, -1,
 863                      "[Aggregate length greater than maximum (%u)]", AGGREGATE_MAX);
 864                  THROW(ReportedBoundsError);
 865              } else {
 866                  return;
 867              }
 868          }
 869   
 870          /*
 871           * Note that we never actually reassemble our A-MPDUs.  Doing
 872           * so would require prepending each MPDU with an A-MPDU delimiter 
 873           * and appending it with padding, only to hand it off to some 
 874           * routine which would un-do the work we just did.  We're using 
 875           * the reassembly code to track MPDU sizes and frame numbers.
 876           */
 877          fd_head = fragment_add_seq_next(tvb, offset, pinfo, ampdu_id,
 878              ampdu_fragment_table, ampdu_reassembled_table,
 879              len_remain, TRUE);
 880          pinfo->fragmented = TRUE;
 881   
 882          /* Do reassembly? */
 883[+]         fd_head = fragment_get(pinfo, ampdu_id, ampdu_fragment_table);
 884   
 885          /* Show our fragments */
 886          if (fd_head && tree) {
 887              ft_fdh = fd_head;
 888              /* List our fragments */
 889              ti = proto_tree_add_text(ppi_tree, tvb, offset, -1, "A-MPDU (%u bytes w/hdrs):", ampdu_len);
 890              PROTO_ITEM_SET_GENERATED(ti);
 891              seg_tree = proto_item_add_subtree(ti, ett_ampdu_segments);
 892   
 893              while (ft_fdh) {
 894                  if (ft_fdh->data && ft_fdh->len) {
 895                      last_frame = ft_fdh->frame;
 896                      if (!first_mpdu)
 897                          proto_item_append_text(ti, ",");
 898                      first_mpdu = FALSE;
 899                      proto_item_append_text(ti, " #%u(%u)",
 900                          ft_fdh->frame, ft_fdh->len);
 901                      proto_tree_add_uint_format(seg_tree, hf_ampdu_segment,
 902                          tvb, 0, 0, last_frame,
 903                          "Frame: %u (%u byte%s)",
 904                          last_frame,
 905                          ft_fdh->len,
 906                          plurality(ft_fdh->len, "", "s"));
 907                  }
 908                  ft_fdh = ft_fdh->next;
 909              }
 910              if (last_frame && last_frame != pinfo->fd->num)
 911                  proto_tree_add_uint(seg_tree, hf_ampdu_reassembled_in,
 912                      tvb, 0, 0, last_frame);
 913          }
 914   
 915          if (fd_head && !DOT11N_MORE_AGGREGATES(n_ext_flags)) {
 916              if (tree) {
 917                  ti = proto_tree_add_protocol_format(tree,
 918[+]                     proto_get_id_by_filter_name("wlan_aggregate"),
 919[+]                     tvb, 0, tot_len, "IEEE 802.11 Aggregate MPDU");
expand/collapse

proto_tree_add_protocol_format

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.c)expand/collapse
Show more  
 1431  proto_item *
 1432  proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
 1433                  gint length, const char *format, ...)
 1434  {
 1435          proto_item              *pi;
 1436          va_list                 ap;
 1437          header_field_info       *hfinfo;
 1438          field_info              *new_fi;
 1439   
 1440          if (!tree)
 1441                  return (NULL);
 1442   
 1443          PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo);
 1444          DISSECTOR_ASSERT(hfinfo->type == FT_PROTOCOL);
 1445   
 1446[+]         pi = proto_tree_add_pi(tree, hfindex, tvb, start, &length, &new_fi);
expand/collapse

proto_tree_add_pi

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.c)expand/collapse
Show more  
 2844  static proto_item *
 2845  proto_tree_add_pi(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
 2846      gint *length, field_info **pfi)
 2847  {
 2848          proto_item      *pi;
 2849          field_info      *fi;
 2850          GHashTable      *hash;
 2851          GPtrArray       *ptrs;
 2852   
 2853          if (!tree)
 2854                  return(NULL);
 2855   
 2856[+]         fi = alloc_field_info(tree, hfindex, tvb, start, length);
expand/collapse

alloc_field_info

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.c)expand/collapse
Show more  
 3041  static field_info *
 3042  alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
 3043      gint *length)
 3044  {
 3045          header_field_info       *hfinfo;
 3046          gint                    item_length;
 3047   
 3048[+]         hfinfo = get_hfi_and_length(hfindex, tvb, start, length, &item_length);
expand/collapse

get_hfi_and_length

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.c)expand/collapse
Show more  
 2879  static header_field_info *
 2880  get_hfi_and_length(int hfindex, tvbuff_t *tvb, gint start, gint *length,
 2881      gint *item_length)
 2882  {
 2883          header_field_info       *hfinfo;
 2884          gint                    length_remaining;
 2885   
 2886          /*
 2887           * We only allow a null tvbuff if the item has a zero length,
 2888           * i.e. if there's no data backing it.
 2889           */
 2890          DISSECTOR_ASSERT(tvb != NULL || *length == 0);
 2891   
 2892          PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo);
Show more  
Show more  
Show more  
Show more  
Show more  




Change Warning 2888.34890 : Cast Alters Value

Priority:
State:
Finding:
Owner:
Note: