Text   |  XML   |  ReML   |   Visible Warnings:

Buffer Underrun  at packet-asn1.c:4368

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

dissect_asn1

(/home/sate/Testcases/c/cve/wireshark-1.2.0/plugins/asn1/packet-asn1.c)expand/collapse
Show more  
 698  dissect_asn1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
 699   
 700    ASN1_SCK asn1;
 701    guint cls, con, tag, len, offset, reassembled;
 702    gboolean def;
 703    char lenstr[BUFLS];
 704    char tagstr[BUFLS];
 705    char headstr[BUFLL];
 706    char offstr[BUFLS];
 707    const char *name, *tname;
 708    volatile guint boffset;
 709    volatile int i = 0;           /* PDU counter */
 710    proto_tree * volatile ti = 0, * volatile ti2 = 0, *asn1_tree, *tree2;
 711    proto_item *hidden_item;
 712    PDUprops props;
 713    static guint lastseq;
 714    struct tcpinfo *info;
 715    gint delta;
 716   
 717    pcount++;
 718    boffset = 0;
 719   
 720    reassembled = 1;              /* UDP is not a stream, and thus always reassembled .... */
 721    if (pinfo->ipproto == IP_PROTO_TCP) { /* we have tcpinfo */
 722            info = (struct tcpinfo *)pinfo->private_data;
 723            delta = info->seq - lastseq;
 724            reassembled = info->is_reassembled;
 725            lastseq = info->seq;
 726   
 727            if (asn1_verbose)
 728                    g_message("dissect_asn1: tcp - seq=%u, delta=%d, reassembled=%d",
 729                              info->seq, delta, reassembled);
 730    } else {
 731            if (asn1_verbose)
 732                    g_message("dissect_asn1: udp");
 733    }
 734   
 735    /* Set the protocol column */
 736    if(check_col(pinfo->cinfo, COL_PROTOCOL)){
 737      col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "ASN.1 %s", current_pduname);
 738    }
 739   
 740[+]   if(check_col(pinfo->cinfo, COL_INFO))
 741      col_clear(pinfo->cinfo, COL_INFO);
 742   
 743   
 744    offstr[0] = 0;
 745    if ((first_pdu_offset > 0) && !reassembled) {
 746            boffset = first_pdu_offset;
 747            g_snprintf(offstr, sizeof(offstr), " at %d", boffset);
 748    }
 749   
 750    /* open BER decoding */
 751    asn1_open(&asn1, tvb, boffset);
 752   
 753[+]   asn1_header_decode(&asn1, &cls, &con, &tag, &def, &len);
 754   
 755    asn1_close(&asn1, &offset);
 756   
 757[+]   PDUreset(pcount, 0);          /* arguments are just for debugging */
 758[+]   getPDUprops(&props, boffset, cls, tag, con);
expand/collapse

getPDUprops

(/home/sate/Testcases/c/cve/wireshark-1.2.0/plugins/asn1/packet-asn1.c)expand/collapse
Show more  
 4283  static PDUprops *
 4284  getPDUprops(PDUprops *out, guint offset, guint class, guint tag, guint cons)
 4285  {
 4286          statestack pos, pos2, save_pos;
 4287          PDUinfo *info;
 4288          const char *ret, *tmp;
 4289          int typeflags = 0, donext = 0, pushed = 0, cons_handled = 0;
 4290          static char namestr[64]; /* enough ? */
 4291          static char posstr[40];
 4292          static char noname[] = "*noname*";
 4293          static PDUprops constructed_save; /* for unexpectedly constructed enteties */
 4294   
 4295          if (PDUstatec > 0)      /* don't read from below the stack */
 4296                  pos = POPSTATE;
 4297          /* pos refers to the last asn1 node handled */
 4298   
 4299          /* a very simple, too simple??, way to handle constructed entities */
 4300          if ((PDUstatec > 0) && (pos.type & TBL_CONSTRUCTED)) {
 4301                          /* unexpectedly constructed, return same info as last time */
 4302                  g_sprintf(posstr, "==off=%d %c%d%c", offset, tag_class[class], tag, cons?'c':'p');
 4303                  showstack(&pos, posstr, 3);
 4304                  pos.offset = offset;
 4305                  pos.type &= ~TBL_CONSTRUCTED; /* remove the flag */
 4306                  PUSHNODE(pos);  /* push extra, to match with a EOI operation */
 4307                  PUSHNODE(pos);  /* restore the stack */
 4308                  *out = constructed_save;
 4309                  if (asn1_verbose)
 4310                          g_message("  return for constructed %s (%s)%s",
 4311                                    TBLTYPE(out->type), out->typename, out->name);
 4312                  return out;
 4313          }
 4314   
 4315          save_pos = pos; /* may need it again */
 4316   
 4317          out->type = 0;
 4318          out->name = 0;
 4319          out->typename = "*error*";
 4320          out->fullname = 0;
 4321          out->flags = 0;
 4322          out->data = 0;
 4323          out->value_id = -1;
 4324          out->type_id = -1;
 4325   
 4326          if (PDUstatec <= 0) {
 4327                  if (PDUstatec > -10) {
 4328                          if (asn1_verbose)
 4329                                  g_message(">>off=%d stack underflow, return", offset);
 4330                  }
 4331                  if (PDUstatec == -10) {
 4332                          if (asn1_verbose)
 4333                                  g_message(">>off=%d stack underflow, return, no more messages", offset);
 4334                  }
 4335                  out->name = "*underflow*";
 4336                  out->flags |= OUT_FLAG_noname;
 4337                  PDUerrcount++;
 4338                  return out;
 4339          }
 4340          g_sprintf(posstr, "==off=%d %c%d%c", offset, tag_class[class], tag, cons?'c':'p');
 4341   
 4342          showstack(&pos, posstr, 3);
 4343   
 4344          ret = noname;
 4345   
 4346          if (class == ASN1_EOI) { /* end of this input sequence */
 4347   
 4348                  if (pos.type & TBL_REFERENCE_pop) { /* reference finished, return to caller */
 4349                          if (asn1_verbose) g_message("    EOI: reference pop");
 4350                          pos = POPSTATE;
 4351                  } else 
 4352                  switch(pos.type & TBL_TYPEmask) {
 4353                  case TBL_TYPEREF:
 4354                          if (asn1_verbose) g_message("    EOI: pop typeref");
 4355                          pos = POPSTATE; /* remove typeref */
 4356                          break;
 4357                  case TBL_CHOICE_done:
 4358                          if (asn1_verbose) g_message("    EOI: mark choice");
 4359                          pos = POPSTATE;
 4360                          pos.type |= TBL_CHOICE_made; /* poropagate this up the stack */
 4361                          PUSHNODE(pos);
 4362                          break;
 4363                  default:
 4364                          break;
 4365                  }
 4366   
 4367   
 4368                  pos = POPSTATE; /* this is pushed back on the stack later */
Show more  
Show more  




Change Warning 3571.33500 : Buffer Underrun

Priority:
State:
Finding:
Owner:
Note: