Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Control Flow  at packet-snmp.c:2751

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

dissect_snmp_pdu

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-snmp.c)expand/collapse
Show more  
 2602  dissect_snmp_pdu(tvbuff_t *tvb, int offset, packet_info *pinfo,
 2603      proto_tree *tree, int proto, gint ett, gboolean is_tcp)
 2604  {
 2605   
 2606          guint length_remaining;
 2607          gint8 class;
 2608          gboolean pc, ind = 0;
 2609          gint32 tag;
 2610          guint32 len;
 2611          guint message_length;
 2612          int start_offset = offset;
 2613          guint32 version = 0;
 2614   
 2615          proto_tree *snmp_tree = NULL;
 2616          proto_item *item = NULL;
 2617          asn1_ctx_t asn1_ctx;
 2618          asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
 2619   
 2620   
 2621          usm_p.msg_tvb = tvb;
 2622          usm_p.start_offset = offset_from_real_beginning(tvb,0) ;
 2623          usm_p.engine_tvb = NULL;
 2624          usm_p.user_tvb = NULL;
 2625          usm_p.auth_item = NULL;
 2626          usm_p.auth_tvb = NULL;
 2627          usm_p.auth_offset = 0;
 2628          usm_p.priv_tvb = NULL;
 2629          usm_p.user_assoc = NULL;
 2630          usm_p.authenticated = FALSE;
 2631          usm_p.encrypted = FALSE;
 2632          usm_p.boots = 0;
 2633          usm_p.time = 0;
 2634          usm_p.authOK = FALSE;
 2635   
 2636          /*
 2637           * This will throw an exception if we don't have any data left.
 2638           * That's what we want.  (See "tcp_dissect_pdus()", which is
 2639           * similar, but doesn't have to deal with ASN.1.
 2640           * XXX - can we make "tcp_dissect_pdus()" provide enough
 2641           * information to the "get_pdu_len" routine so that we could 
 2642           * have that routine deal with ASN.1, and just use 
 2643           * "tcp_dissect_pdus()"?)
 2644           */
 2645          length_remaining = tvb_ensure_length_remaining(tvb, offset);
 2646   
 2647          /* NOTE: we have to parse the message piece by piece, since the
 2648           * capture length may be less than the message length: a 'global'
 2649           * parsing is likely to fail.
 2650           */
 2651   
 2652          /*
 2653           * If this is SNMP-over-TCP, we might have to do reassembly
 2654           * in order to read the "Sequence Of" header.
 2655           */
 2656          if (is_tcp && snmp_desegment && pinfo->can_desegment) {
 2657                  /*
 2658                   * This is TCP, and we should, and can, do reassembly.
 2659                   *
 2660                   * Is the "Sequence Of" header split across segment
 2661                   * boundaries?  We requre at least 6 bytes for the 
 2662                   * header, which allows for a 4-byte length (ASN.1
 2663                   * BER).
 2664                   */
 2665                  if (length_remaining < 6) {
 2666                          pinfo->desegment_offset = offset;
 2667                          pinfo->desegment_len = 6 - length_remaining;
 2668   
 2669                          /*
 2670                           * Return 0, which means "I didn't dissect anything
 2671                           * because I don't have enough data - we need
 2672                           * to desegment".
 2673                           */
 2674                          return 0;
 2675                  }
 2676          }
 2677   
 2678          /*
 2679           * OK, try to read the "Sequence Of" header; this gets the total
 2680           * length of the SNMP message.
 2681           */
 2682          /* Set tree to 0 to not display internakl BER fields if option used.*/
 2683          offset = dissect_ber_identifier(pinfo, 0, tvb, offset, &class, &pc, &tag);
 2684          offset = dissect_ber_length(pinfo, 0, tvb, offset, &len, &ind);
 2685   
 2686          message_length = len + 2;
 2687          offset = dissect_ber_integer(FALSE, &asn1_ctx, 0, tvb, offset, -1, &version);
 2688   
 2689   
 2690          /*
 2691           * If this is SNMP-over-TCP, we might have to do reassembly
 2692           * to get all of this message.
 2693           */
 2694          if (is_tcp && snmp_desegment && pinfo->can_desegment) {
 2695                  /*
 2696                   * Yes - is the message split across segment boundaries?
 2697                   */
 2698                  if (length_remaining < message_length) {
 2699                          /*
 2700                           * Yes.  Tell the TCP dissector where the data
 2701                           * for this message starts in the data it handed 
 2702                           * us, and how many more bytes we need, and 
 2703                           * return.
 2704                           */
 2705                          pinfo->desegment_offset = start_offset;
 2706                          pinfo->desegment_len =
 2707                              message_length - length_remaining;
 2708   
 2709                          /*
 2710                           * Return 0, which means "I didn't dissect anything
 2711                           * because I don't have enough data - we need
 2712                           * to desegment".
 2713                           */
 2714                          return 0;
 2715                  }
 2716          }
 2717   
 2718          next_tvb_init(&var_list);
 2719   
 2720          if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
 2721                  col_set_str(pinfo->cinfo, COL_PROTOCOL,
 2722                      proto_get_protocol_short_name(find_protocol_by_id(proto)));
 2723          }
 2724   
 2725          if (tree) {
 2726                  item = proto_tree_add_item(tree, proto, tvb, offset,
 2727                      message_length, FALSE);
 2728                  snmp_tree = proto_item_add_subtree(item, ett);
 2729          }
 2730   
 2731          switch (version){
 2732          case 0: /* v1 */
 2733          case 1: /* v2c */
 2734                  offset = dissect_snmp_Message(FALSE , tvb, start_offset, &asn1_ctx, snmp_tree, -1);
 2735                  break;
 2736          case 2: /* v2u */
 2737                  offset = dissect_snmp_Messagev2u(FALSE , tvb, start_offset, &asn1_ctx, snmp_tree, -1);
 2738                  break;
 2739                          /* v3 */
 2740          case 3:
 2741                  offset = dissect_snmp_SNMPv3Message(FALSE , tvb, start_offset, &asn1_ctx, snmp_tree, -1);
 2742                  break;
 2743          default:
 2744                  /*
 2745                   * Return the length remaining in the tvbuff, so 
 2746                   * if this is SNMP-over-TCP, our caller thinks there's
 2747                   * nothing left to dissect.
 2748                   */
 2749                  proto_tree_add_text(snmp_tree, tvb, offset, -1,"Unknown version");
 2750                  return length_remaining;
 2751                  break;
 2752          }
 2753   
 2754          next_tvb_call(&var_list, pinfo, tree, NULL, data_handle);
 2755   
 2756          return offset;
 2757  }
Show more  




Change Warning 1643.35145 : Unreachable Control Flow

Priority:
State:
Finding:
Owner:
Note: