Text   |  XML   |  ReML   |   Visible Warnings:

Null Test After Dereference  at packet-ipv6.c:524

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

dissect_ipv6_options

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ipv6.c)expand/collapse
Show more  
 454  dissect_ipv6_options(tvbuff_t *tvb, int offset, guint length,
 455                          const ip_tcp_opt *opttab, int nopts, int eol,
 456                          packet_info *pinfo, proto_tree *opt_tree)
 457  {
 458    guchar            opt;
 459    const ip_tcp_opt *optp;
 460    opt_len_type      len_type;
 461    unsigned int      optlen;
 462    const char       *name;
 463    char              name_str[7+1+1+2+2+1+1];    /* "Unknown (0x%02x)" */
 464    void            (*dissect)(const struct ip_tcp_opt *, tvbuff_t *,
 465                                  int, guint, packet_info *, proto_tree *);
 466    guint             len;
 467   
 468    while (length > 0) {
 469      opt = tvb_get_guint8(tvb, offset);
 470      for (optp = &opttab[0]; optp < &opttab[nopts]; optp++) {
 471        if (optp->optcode == opt)
 472          break;
 473      }
 474      if (optp == &opttab[nopts]) {
 475        /* We assume that the only NO_LENGTH options are Pad1 options,
 476           so that we can treat unknown options as VARIABLE_LENGTH with a
 477           minimum of 0, and at least be able to move on to the next option
 478           by using the length in the option. */
 479        optp = NULL;      /* indicate that we don't know this option */
 480        len_type = VARIABLE_LENGTH;
 481        optlen = 0;
 482        g_snprintf(name_str, sizeof name_str, "Unknown (0x%02x)", opt);
 483        name = name_str;
 484        dissect = NULL;
 485      } else {
 486        len_type = optp->len_type;
 487        optlen = optp->optlen;
 488        name = optp->name;
 489        dissect = optp->dissect;
 490      }
 491      --length;      /*  for type byte */
 492      if (len_type != NO_LENGTH) {
 493        /* Option has a length. Is it in the packet? */
 494        if (length == 0) {
 495          /* Bogus - packet must at least include option code byte and 
 496             length byte! */
 497          proto_tree_add_text(opt_tree, tvb, offset,      1,
 498                "%s (length byte past end of options)", name);
 499          return;
 500        }
 501        len = tvb_get_guint8(tvb, offset + 1);  /* total including type, len */
 502        --length;    /*  for length byte */
 503        if (len > length) {
 504          /* Bogus - option goes past the end of the header. */
 505          proto_tree_add_text(opt_tree, tvb, offset,      length,
 506                "%s (option length = %u byte%s says option goes past end of options)",
 507                name, len, plurality(len, "", "s"));
 508          return;
 509        } else if (len_type == FIXED_LENGTH && len != optlen) {
 510          /* Bogus - option length isn't what it's supposed to be for this 
 511             option. */
 512          proto_tree_add_text(opt_tree, tvb, offset,      2 + len,
 513                "%s (with option length = %u byte%s; should be %u)", name,
 514                len, plurality(len, "", "s"), optlen);
 515          return;
 516        } else if (len_type == VARIABLE_LENGTH && len < optlen) {
 517          /* Bogus - option length is less than what it's supposed to be for
 518             this option. */
 519          proto_tree_add_text(opt_tree, tvb, offset,      2 + len,
 520                "%s (with option length = %u byte%s; should be >= %u)", name,
 521                len, plurality(len, "", "s"), optlen);
 522          return;
 523        } else {
 524          if (optp == NULL) {
 525            proto_tree_add_text(opt_tree, tvb, offset,    2 + len, "%s (%u byte%s)",
 526                                  name, len, plurality(len, "", "s"));
 527          } else {
 528            if (dissect != NULL) {
 529              /* Option has a dissector. */
 530              (*dissect)(optp, tvb, offset,          2 + len, pinfo, opt_tree);
 531            } else {
 532              /* Option has no data, hence no dissector. */
 533              proto_tree_add_text(opt_tree, tvb, offset,  2 + len, "%s", name);
 534            }
 535          }
 536          offset += 2 + len;
 537        }
 538        length -= len;
 539      } else {
 540        proto_tree_add_text(opt_tree, tvb, offset,      1, "%s", name);
 541        offset += 1;
 542      }
 543      if (opt == eol)
 544        break;
 545    }
 546  }
Show more  




Change Warning 12332.31412 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: