Text   |  XML   |  ReML   |   Visible Warnings:

Cast Alters Value  at packet-ber.c:3954

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

dissect_ber_bitstring

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ber.c)expand/collapse
Show more  
 3878  int dissect_ber_bitstring(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *parent_tree, tvbuff_t *tvb, int offset, const asn_namedbit *named_bits, gint hf_id, gint ett_id, tvbuff_t **out_tvb)
 3879  {
 3880          gint8 class;
 3881          gboolean pc, ind;
 3882          gint32 tag;
 3883          guint32 len;
 3884          guint8 pad=0, b0, b1, val;
 3885          int end_offset;
 3886          int hoffset;
 3887          proto_item *item = NULL;
 3888          proto_item *cause;
 3889          proto_tree *tree = NULL;
 3890          const asn_namedbit *nb;
 3891          const char *sep;
 3892          gboolean term;
 3893   
 3894          if(!implicit_tag){
 3895            hoffset = offset;
 3896            /* read header and len for the octet string */
 3897            offset = dissect_ber_identifier(actx->pinfo, parent_tree, tvb, offset, &class, &pc, &tag);
 3898            offset = dissect_ber_length(actx->pinfo, parent_tree, tvb, offset, &len, &ind);
 3899            end_offset = offset + len;
 3900   
 3901            /* sanity check: we only handle Universal BitSrings */
 3902   
 3903            /* for an IMPLICIT APPLICATION tag asn2eth seems to call this
 3904               function with implicit_tag = FALSE. BER_FLAGS_NOOWNTAG was
 3905               set so the APPLICATION tag was still present.
 3906               So here we relax it for APPLICATION tags. CONTEXT tags may 
 3907               still cause a problem. */
 3908   
 3909            if(!implicit_tag && (class!=BER_CLASS_APP)) {
 3910                  if( (class!=BER_CLASS_UNI)
 3911                    ||(tag!=BER_UNI_TAG_BITSTRING) ){
 3912                      tvb_ensure_bytes_exist(tvb, hoffset, 2);
 3913                      cause = proto_tree_add_text(parent_tree, tvb, offset, len, "BER Error: BitString expected but class:%s(%d) %s tag:%d was unexpected", val_to_str(class,ber_class_codes,"Unknown"), class, pc ? ber_pc_codes_short.true_string : ber_pc_codes_short.false_string, tag);
 3914                      proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN);
 3915                      expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN, "BER Error: BitString expected");
 3916                      if (decode_unexpected) {
 3917                        proto_tree *unknown_tree = proto_item_add_subtree(cause, ett_ber_unknown);
 3918                        dissect_unknown_ber(actx->pinfo, tvb, hoffset, unknown_tree);
 3919                      }
 3920                      return end_offset;
 3921                  }
 3922            }
 3923          } else {
 3924            pc=0;
 3925            len=tvb_length_remaining(tvb,offset);
 3926            end_offset=offset+len;
 3927          }
 3928   
 3929          actx->created_item = NULL;
 3930   
 3931          if(pc) {
 3932                  /* constructed */
 3933                  /* TO DO */
 3934          } else {
 3935                  /* primitive */
 3936                  pad = tvb_get_guint8(tvb, offset);
 3937                  if(pad == 0 && len == 1) {
 3938                          /* empty */
 3939                          proto_tree_add_item(parent_tree, hf_ber_bitstring_empty, tvb, offset, 1, FALSE);
 3940                  } else {
 3941                          /* padding */
 3942                          proto_tree_add_item(parent_tree, hf_ber_bitstring_padding, tvb, offset, 1, FALSE);
 3943                  }
 3944                  offset++;
 3945                  len--;
 3946                  if( hf_id >= 0) {
 3947                          item = proto_tree_add_item(parent_tree, hf_id, tvb, offset, len, FALSE);
 3948                          actx->created_item= item;
 3949                          if(ett_id != -1) {
 3950                                  tree = proto_item_add_subtree(item, ett_id);
 3951                          }
 3952                  }
 3953                  if(out_tvb) {
 3954[+]                         if(len<=(guint32)tvb_length_remaining(tvb, offset)){
Show more  




Change Warning 1217.31893 : Cast Alters Value

Priority:
State:
Finding:
Owner:
Note: