Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Data Flow  at packet-ospf.c:1384

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

dissect_ospf

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ospf.c)expand/collapse
Show more  
 1232  dissect_ospf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 1233  {
 1234      proto_tree *ospf_tree = NULL;
 1235      proto_item *ti, *hidden_item;
 1236      proto_tree *ospf_header_tree;
 1237      guint8  version;
 1238      guint8  packet_type;
 1239      guint16 ospflen;
 1240      vec_t cksum_vec[4];
 1241      int cksum_vec_len;
 1242      guint32 phdr[2];
 1243      guint16 cksum, computed_cksum;
 1244      guint length, reported_length;
 1245      guint16 auth_type;
 1246      char auth_data[8+1];
 1247      int crypto_len = 0;
 1248      unsigned int ospf_header_length;
 1249      guint8 instance_ID;
 1250      guint8 reserved;
 1251      guint32 areaid;
 1252      guint8  address_family = OSPF_AF_6;
 1253   
 1254      if (check_col(pinfo->cinfo, COL_PROTOCOL))
 1255          col_set_str(pinfo->cinfo, COL_PROTOCOL, "OSPF");
 1256      if (check_col(pinfo->cinfo, COL_INFO))
 1257          col_clear(pinfo->cinfo, COL_INFO);
 1258   
 1259      version = tvb_get_guint8(tvb, 0);
 1260      switch (version) {
 1261          case OSPF_VERSION_2:
 1262              ospf_header_length = OSPF_VERSION_2_HEADER_LENGTH;
 1263              break;
 1264          case OSPF_VERSION_3:
 1265              ospf_header_length = OSPF_VERSION_3_HEADER_LENGTH;
 1266              break;
 1267          default:
 1268              ospf_header_length = 14;
 1269              break;
 1270      }
 1271   
 1272      packet_type = tvb_get_guint8(tvb, 1);
 1273      if (check_col(pinfo->cinfo, COL_INFO)) {
 1274          col_add_str(pinfo->cinfo, COL_INFO,
 1275                      val_to_str(packet_type, pt_vals, "Unknown (%u)"));
 1276      }
 1277   
 1278      if (tree) {
 1279          ospflen = tvb_get_ntohs(tvb, 2);
 1280   
 1281          ti = proto_tree_add_item(tree, proto_ospf, tvb, 0, -1, FALSE);
 1282          ospf_tree = proto_item_add_subtree(ti, ett_ospf);
 1283   
 1284          ti = proto_tree_add_text(ospf_tree, tvb, 0, ospf_header_length,
 1285                                   "OSPF Header");
 1286          ospf_header_tree = proto_item_add_subtree(ti, ett_ospf_hdr);
 1287   
 1288          proto_tree_add_text(ospf_header_tree, tvb, 0, 1, "OSPF Version: %u",
 1289                              version);
 1290          proto_tree_add_item(ospf_header_tree, ospf_filter[OSPFF_MSG_TYPE],
 1291                              tvb, 1, 1, FALSE);
 1292          if (ospf_msg_type_to_filter(packet_type) != -1) {
 1293                  hidden_item = proto_tree_add_item(ospf_header_tree,
 1294                                             ospf_filter[ospf_msg_type_to_filter(packet_type)],
 1295                                             tvb, 1, 1, FALSE);
 1296                  PROTO_ITEM_SET_HIDDEN(hidden_item);
 1297          }
 1298          proto_tree_add_text(ospf_header_tree, tvb, 2, 2, "Packet Length: %u",
 1299                              ospflen);
 1300          proto_tree_add_item(ospf_header_tree, ospf_filter[OSPFF_SRC_ROUTER],
 1301                              tvb, 4, 4, FALSE);
 1302          areaid=tvb_get_ntohl(tvb,8);
 1303          proto_tree_add_text(ospf_header_tree, tvb, 8, 4, "Area ID: %s%s",
 1304                                 ip_to_str(tvb_get_ptr(tvb, 8, 4)), areaid == 0 ? " (Backbone)" : "");
 1305   
 1306          /*
 1307           * Quit at this point if it's an unknown OSPF version.
 1308           */
 1309          switch (version) {
 1310   
 1311          case OSPF_VERSION_2:
 1312          case OSPF_VERSION_3:
 1313              break;
 1314   
 1315          default:
 1316              cksum = tvb_get_ntohs(tvb, 12);
 1317              if (cksum == 0) {
 1318                  /* No checksum supplied in the packet. */
 1319                  proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
 1320                      "Packet Checksum: 0x%04x (none)", cksum);
 1321              } else {
 1322                  proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
 1323                      "Packet Checksum: 0x%04x", cksum);
 1324              }
 1325              proto_tree_add_text(ospf_tree, tvb, 14, -1,
 1326                  "Unknown OSPF version %u", version);
 1327              return;
 1328          }
 1329   
 1330          cksum = tvb_get_ntohs(tvb, 12);
 1331          length = tvb_length(tvb);
 1332          /* XXX - include only the length from the OSPF header? */
 1333          reported_length = tvb_reported_length(tvb);
 1334          if (cksum == 0) {
 1335              /* No checksum supplied in the packet. */
 1336              proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
 1337                  "Packet Checksum: 0x%04x (none)", cksum);
 1338          } else if (!pinfo->fragmented && length >= reported_length 
 1339                  && length >= ospf_header_length) {
 1340              /* The packet isn't part of a fragmented datagram and isn't
 1341                 truncated, so we can checksum it. */
 1342   
 1343              switch (version) {
 1344   
 1345              case OSPF_VERSION_2:
 1346                  /* Header, not including the authentication data (the OSPFv2 
 1347                     checksum excludes the 64-bit authentication field). */
 1348                  cksum_vec[0].ptr = tvb_get_ptr(tvb, 0, 16);
 1349                  cksum_vec[0].len = 16;
 1350                  if (length > ospf_header_length) {
 1351                      /* Rest of the packet, again not including the
 1352                         authentication data. */
 1353                      reported_length -= ospf_header_length;
 1354                      cksum_vec[1].ptr = tvb_get_ptr(tvb, ospf_header_length, reported_length);
 1355                      cksum_vec[1].len = reported_length;
 1356                      cksum_vec_len = 2;
 1357                  } else {
 1358                      /* There's nothing but a header. */
 1359                      cksum_vec_len = 1;
 1360                  }
 1361                  break;
 1362   
 1363              case OSPF_VERSION_3:
 1364                  /* IPv6-style checksum, covering the entire OSPF packet 
 1365                     and a prepended IPv6 pseudo-header. */
 1366   
 1367                  /* Set up the fields of the pseudo-header. */
 1368                  cksum_vec[0].ptr = pinfo->src.data;
 1369                  cksum_vec[0].len = pinfo->src.len;
 1370                  cksum_vec[1].ptr = pinfo->dst.data;
 1371                  cksum_vec[1].len = pinfo->dst.len;
 1372                  cksum_vec[2].ptr = (const guint8 *)&phdr;
 1373                  phdr[0] = g_htonl(ospflen);
 1374                  phdr[1] = g_htonl(IP_PROTO_OSPF);
 1375                  cksum_vec[2].len = 8;
 1376   
 1377                  cksum_vec[3].ptr = tvb_get_ptr(tvb, 0, reported_length);
 1378                  cksum_vec[3].len = reported_length;
 1379                  cksum_vec_len = 4;
 1380                  break;
 1381   
 1382              default:
 1383                  DISSECTOR_ASSERT_NOT_REACHED();
 1384                  cksum_vec_len = 0;
 1385                  break;
 1386              }
 1387              computed_cksum = in_cksum(cksum_vec, cksum_vec_len);
 1388              if (computed_cksum == 0) {
 1389                  proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
 1390                          "Packet Checksum: 0x%04x [correct]", cksum);
 1391              } else {
 1392                  proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
 1393                          "Packet Checksum: 0x%04x [incorrect, should be 0x%04x]",
 1394                          cksum, in_cksum_shouldbe(cksum, computed_cksum));
 1395              }
 1396          } else {
 1397              proto_tree_add_text(ospf_header_tree, tvb, 12, 2,
 1398                  "Packet Checksum: 0x%04x", cksum);
 1399          }
 1400   
 1401   
 1402          switch (version) {
 1403   
 1404          case OSPF_VERSION_2:
 1405              /* Authentication is only valid for OSPFv2 */
 1406              auth_type = tvb_get_ntohs(tvb, 14);
 1407              proto_tree_add_text(ospf_header_tree, tvb, 14, 2, "Auth Type: %s",
 1408                              val_to_str(auth_type, auth_vals, "Unknown (%u)"));
 1409              switch (auth_type) {
 1410   
 1411              case OSPF_AUTH_NONE:
 1412                  proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data (none)");
 1413                  break;
 1414   
 1415              case OSPF_AUTH_SIMPLE:
 1416                  tvb_get_nstringz0(tvb, 16, 8+1, auth_data);
 1417                  proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data: %s", auth_data);
 1418                  break;
 1419   
 1420              case OSPF_AUTH_CRYPT:
 1421                  proto_tree_add_text(ospf_header_tree, tvb, 18, 1, "Auth Key ID: %u",
 1422                                  tvb_get_guint8(tvb, 18));
 1423                  crypto_len = tvb_get_guint8(tvb, 19);
 1424                  proto_tree_add_text(ospf_header_tree, tvb, 19, 1, "Auth Data Length: %u",
 1425                                  crypto_len);
 1426                  proto_tree_add_text(ospf_header_tree, tvb, 20, 4, "Auth Crypto Sequence Number: 0x%x",
 1427                                  tvb_get_ntohl(tvb, 20));
 1428   
 1429                  /* Show the message digest that was appended to the end of the
 1430                     OSPF message - but only if it's present (we don't want 
 1431                     to get an exception before we've tried dissecting OSPF 
 1432                     message). */
 1433                  if (tvb_bytes_exist(tvb, ospflen, crypto_len)) {
 1434                      proto_tree_add_text(ospf_header_tree, tvb, ospflen, crypto_len,
 1435                                      "Auth Data: %s",
 1436                                      tvb_bytes_to_str(tvb, ospflen, crypto_len));
 1437                      proto_tree_set_appendix(ospf_header_tree, tvb, ospflen, crypto_len);
 1438                  }
 1439                  break;
 1440   
 1441              default:
 1442                  proto_tree_add_text(ospf_header_tree, tvb, 16, 8, "Auth Data (unknown)");
 1443                  break;
 1444              }
 1445              break;
 1446   
 1447          case OSPF_VERSION_3:
 1448              /* Instance ID and "reserved" is OSPFv3-only */
 1449              instance_ID = tvb_get_guint8(tvb, 14);
 1450              ti = proto_tree_add_text(ospf_header_tree, tvb, 14, 1, "Instance ID: %u",
 1451                              instance_ID);
 1452   
 1453              if (instance_ID < 32) {
 1454                  proto_item_append_text(ti, " (IPv6 unicast AF)");
 1455                  address_family = OSPF_AF_6;
 1456              } else if (instance_ID < 64) {
 1457                  proto_item_append_text(ti, " (IPv6 multicast AF)");
 1458                  address_family = OSPF_AF_6;
 1459              } else if (instance_ID < 96) {
 1460                  proto_item_append_text(ti, " (IPv4 unicast AF)");
 1461                  address_family = OSPF_AF_4;
 1462              } else if (instance_ID < 128) {
 1463                  proto_item_append_text(ti, " (IPv4 multicast AF)");
 1464                  address_family = OSPF_AF_4;
 1465              } else {
 1466                  proto_item_append_text(ti, " (Reserved)");
 1467                  address_family = OSPF_AF_6;
 1468              }
 1469   
 1470              reserved = tvb_get_guint8(tvb, 15);
 1471              proto_tree_add_text(ospf_header_tree, tvb, 15, 1, (reserved == 0 ? "Reserved: %u" : "Reserved: %u [incorrect, should be 0]"),
 1472                                  reserved);
 1473              break;
 1474          }
 1475   
 1476          switch (packet_type){
 1477   
 1478          case OSPF_HELLO:
 1479              dissect_ospf_hello(tvb, ospf_header_length, ospf_tree, version,
 1480                              (guint16)(ospflen - ospf_header_length));
 1481              break;
 1482   
 1483          case OSPF_DB_DESC:
 1484              dissect_ospf_db_desc(tvb, (int)ospf_header_length, ospf_tree, version,
 1485                                   (guint16)(ospflen - ospf_header_length),
 1486                                   address_family);
 1487              break;
 1488   
 1489          case OSPF_LS_REQ:
 1490              dissect_ospf_ls_req(tvb, (int)ospf_header_length, ospf_tree, version,
 1491                                  (guint16)(ospflen - ospf_header_length));
 1492              break;
 1493   
 1494          case OSPF_LS_UPD:
 1495              dissect_ospf_ls_upd(tvb, (int)ospf_header_length, ospf_tree, version,
 1496                                  (guint16)(ospflen - ospf_header_length),
 1497                                  address_family);
 1498              break;
 1499   
 1500          case OSPF_LS_ACK:
 1501              dissect_ospf_ls_ack(tvb, (int)ospf_header_length, ospf_tree, version,
 1502                                  (guint16)(ospflen - ospf_header_length),
 1503                                  address_family);
 1504              break;
 1505   
 1506          default:
 1507              call_dissector(data_handle,
 1508                  tvb_new_subset(tvb, ospf_header_length, -1, -1), pinfo, tree);
 1509              break;
 1510          }
 1511   
 1512          /* take care of the LLS data block */
 1513          if (ospf_has_lls_block(tvb, ospf_header_length, packet_type, version)) {
 1514              dissect_ospf_lls_data_block(tvb, ospflen + crypto_len, ospf_tree,
 1515                              version);
 1516          }
 1517      }
 1518  }
Show more  




Change Warning 2874.34888 : Unreachable Data Flow

Priority:
State:
Finding:
Owner:
Note: