Text   |  XML   |  ReML   |   Visible Warnings:

Null Test After Dereference  at packet-ip.c:1275

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

dissect_ip_tcp_options

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ip.c)expand/collapse
Show more  
 1200  dissect_ip_tcp_options(tvbuff_t *tvb, int offset, guint length,
 1201                          const ip_tcp_opt *opttab, int nopts, int eol,
 1202                          packet_info *pinfo, proto_tree *opt_tree)
 1203  {
 1204    guchar            opt;
 1205    const ip_tcp_opt *optp;
 1206    opt_len_type      len_type;
 1207    unsigned int      optlen;
 1208    const char       *name;
 1209    void            (*dissect)(const struct ip_tcp_opt *, tvbuff_t *,
 1210                                  int, guint, packet_info *, proto_tree *);
 1211    guint             len;
 1212   
 1213    while (length > 0) {
 1214      opt = tvb_get_guint8(tvb, offset);
 1215      for (optp = &opttab[0]; optp < &opttab[nopts]; optp++) {
 1216        if (optp->optcode == opt)
 1217          break;
 1218      }
 1219      if (optp == &opttab[nopts]) {
 1220        /* We assume that the only NO_LENGTH options are EOL and NOP options,
 1221           so that we can treat unknown options as VARIABLE_LENGTH with a
 1222           minimum of 2, and at least be able to move on to the next option
 1223           by using the length in the option. */
 1224        optp = NULL;      /* indicate that we don't know this option */
 1225        len_type = VARIABLE_LENGTH;
 1226        optlen = 2;
 1227        name = ep_strdup_printf("Unknown (0x%02x)", opt);
 1228        dissect = NULL;
 1229      } else {
 1230        len_type = optp->len_type;
 1231        optlen = optp->optlen;
 1232        name = optp->name;
 1233        dissect = optp->dissect;
 1234      }
 1235      --length;      /*  for type byte */
 1236      if (len_type != NO_LENGTH) {
 1237        /* Option has a length. Is it in the packet? */
 1238        if (length == 0) {
 1239          /* Bogus - packet must at least include option code byte and 
 1240             length byte! */
 1241          proto_tree_add_text(opt_tree, tvb, offset,      1,
 1242                "%s (length byte past end of options)", name);
 1243          return;
 1244        }
 1245        len = tvb_get_guint8(tvb, offset + 1);  /* total including type, len */
 1246        --length;    /*  for length byte */
 1247        if (len < 2) {
 1248          /* Bogus - option length is too short to include option code and
 1249             option length. */
 1250          proto_tree_add_text(opt_tree, tvb, offset,      2,
 1251                "%s (with too-short option length = %u byte%s)", name,
 1252                len, plurality(len, "", "s"));
 1253          return;
 1254        } else if (len - 2 > length) {
 1255          /* Bogus - option goes past the end of the header. */
 1256          proto_tree_add_text(opt_tree, tvb, offset,      length,
 1257                "%s (option length = %u byte%s says option goes past end of options)",
 1258                name, len, plurality(len, "", "s"));
 1259          return;
 1260        } else if (len_type == FIXED_LENGTH && len != optlen) {
 1261          /* Bogus - option length isn't what it's supposed to be for this 
 1262             option. */
 1263          proto_tree_add_text(opt_tree, tvb, offset,      len,
 1264                "%s (with option length = %u byte%s; should be %u)", name,
 1265                len, plurality(len, "", "s"), optlen);
 1266          return;
 1267        } else if (len_type == VARIABLE_LENGTH && len < optlen) {
 1268          /* Bogus - option length is less than what it's supposed to be for
 1269             this option. */
 1270          proto_tree_add_text(opt_tree, tvb, offset,      len,
 1271                "%s (with option length = %u byte%s; should be >= %u)", name,
 1272                len, plurality(len, "", "s"), optlen);
 1273          return;
 1274        } else {
 1275          if (optp == NULL) {
 1276            proto_tree_add_text(opt_tree, tvb, offset,    len, "%s (%u byte%s)",
 1277                                  name, len, plurality(len, "", "s"));
 1278          } else {
 1279            if (dissect != NULL) {
 1280              /* Option has a dissector. */
 1281              (*dissect)(optp, tvb, offset,          len, pinfo, opt_tree);
 1282            } else {
 1283              /* Option has no data, hence no dissector. */
 1284              proto_tree_add_text(opt_tree, tvb, offset,  len, "%s", name);
 1285            }
 1286          }
 1287          len -= 2;       /* subtract size of type and length */
 1288          offset += 2 + len;
 1289        }
 1290        length -= len;
 1291      } else {
 1292        proto_tree_add_text(opt_tree, tvb, offset,      1, "%s", name);
 1293        offset += 1;
 1294      }
 1295      if (opt == eol)
 1296        break;
 1297    }
 1298  }
Show more  




Change Warning 12327.31286 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: