Text   |  XML   |  ReML   |   Visible Warnings:

Null Test After Dereference  at packet-mip6.c:791

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

dissect_mipv6_options

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-mip6.c)expand/collapse
Show more  
 719  dissect_mipv6_options(tvbuff_t *tvb, int offset, guint length,
 720                        const ip_tcp_opt *opttab, int nopts, int eol,
 721                        packet_info *pinfo, proto_tree *opt_tree)
 722  {
 723          guchar            opt;
 724          const ip_tcp_opt  *optp;
 725          opt_len_type      len_type;
 726          unsigned int      optlen;
 727          const char        *name;
 728          char              name_str[7+1+1+2+2+1+1];      /* "Unknown (0x%02x)" */
 729          void              (*dissect)(const struct ip_tcp_opt *, tvbuff_t *,
 730                                       int, guint, packet_info *, proto_tree *);
 731          guint             len;
 732   
 733          while (length > 0) {
 734                  opt = tvb_get_guint8(tvb, offset);
 735                  for (optp = &opttab[0]; optp < &opttab[nopts]; optp++) {
 736                          if (optp->optcode == opt)
 737                                  break;
 738                  }
 739                  if (optp == &opttab[nopts]) {
 740                          /* We assume that the only NO_LENGTH options are Pad1 options,
 741                           * so that we can treat unknown options as VARIABLE_LENGTH with a 
 742                           * minimum of 0, and at least be able to move on to the next option
 743                           * by using the length in the option.
 744                           */
 745                          optp = NULL;    /* indicate that we don't know this option */
 746                          len_type = VARIABLE_LENGTH;
 747                          optlen = 0;
 748                          g_snprintf(name_str, sizeof name_str, "Unknown (0x%02x)", opt);
 749                          name = name_str;
 750                          dissect = NULL;
 751                  } else {
 752                          len_type = optp->len_type;
 753                          optlen = optp->optlen;
 754                          name = optp->name;
 755                          dissect = optp->dissect;
 756                  }
 757                  --length;      /*  for type byte */
 758                  if (len_type != NO_LENGTH) {
 759                          /* Option has a length. Is it in the packet? */
 760                          if (length == 0) {
 761                                  /* Bogus - packet must at least include 
 762                                   * option code byte and length byte!
 763                                   */
 764                                  proto_tree_add_text(opt_tree, tvb, offset,      1,
 765                                                  "%s (length byte past end of options)", name);
 766                                  return;
 767                          }
 768                          len = tvb_get_guint8(tvb, offset + 1);  /* Size specified in option */
 769                          --length;    /*  for length byte */
 770                          if (len > length) {
 771                                  /* Bogus - option goes past the end of the header. */
 772                                  proto_tree_add_text(opt_tree, tvb, offset,      length,
 773                                                  "%s (option length = %u byte%s says option goes past end of options)",
 774                                                  name, len, plurality(len, "", "s"));
 775                                  return;
 776                          } else if (len_type == FIXED_LENGTH && len != optlen) {
 777                                  /* Bogus - option length isn't what it's supposed to be for this 
 778                                     option. */
 779                                  proto_tree_add_text(opt_tree, tvb, offset, len + 2,
 780                                                  "%s (with option length = %u byte%s; should be %u)", name,
 781                                                  len, plurality(len, "", "s"), optlen);
 782                                  return;
 783                          } else if (len_type == VARIABLE_LENGTH && len < optlen) {
 784                                  /* Bogus - option length is less than what it's supposed to be for
 785                                     this option. */
 786                                  proto_tree_add_text(opt_tree, tvb, offset, len + 2,
 787                                                  "%s (with option length = %u byte%s; should be >= %u)", name,
 788                                                  len, plurality(len, "", "s"), optlen);
 789                                  return;
 790                          } else {
 791                                  if (optp == NULL) {
 792                                          proto_tree_add_text(opt_tree, tvb, offset, len + 2, "%s (%u byte%s)",
 793                                                          name, len, plurality(len, "", "s"));
 794                                  } else {
 795                                          if (dissect != NULL) {
 796                                                  /* Option has a dissector. */
 797                                                  if (opt == LLA)
 798                                                          (*dissect)(optp, tvb, offset,
 799                                                                     len + 2 + FMIP6_LLA_OPTCODE_LEN, pinfo, opt_tree);
 800                                                  else 
 801                                                          (*dissect)(optp, tvb, offset, len + 2, pinfo, opt_tree);
 802                                          } else {
 803                                                  /* Option has no data, hence no dissector. */
 804                                                  proto_tree_add_text(opt_tree, tvb, offset, len + 2, "%s", name);
 805                                          }
 806                                  }
 807                                  /* RFC4068 Section 6.4.4
 808                                   *   Length         The size of this option in octets not including the 
 809                                   *                  Type, Length, and Option-Code fields.
 810                                   */
 811                                  if (opt == LLA)
 812                                          offset += len + 2 + FMIP6_LLA_OPTCODE_LEN;
 813                                  else 
 814                                          offset += len + 2;
 815                          }
 816                          if (opt == LLA)
 817                                  length -= (len + FMIP6_LLA_OPTCODE_LEN);
 818                          else 
 819                                  length -= len;
 820                  } else {
 821                          proto_tree_add_text(opt_tree, tvb, offset, 1, "%s", name);
 822                          offset += 1;
 823                  }
 824                  if (opt == eol)
 825                          break;
 826          }
 827  }
Show more  




Change Warning 12328.31287 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: