Text   |  XML   |  ReML   |   Visible Warnings:

Buffer Overrun  at packet-ssl.c:1794

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

dissect_ssl3_record

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ssl.c)expand/collapse
Show more  
 1284  dissect_ssl3_record(tvbuff_t *tvb, packet_info *pinfo,
 1285                      proto_tree *tree, guint32 offset,
 1286                      guint *conv_version, gboolean *need_desegmentation,
 1287                      SslDecryptSession* ssl, gboolean first_record_in_frame _U_)
 1288  {
 1289   
 1290      /*
 1291       *    struct {
 1292       *        uint8 major, minor;
 1293       *    } ProtocolVersion;
 1294       *
 1295       *
 1296       *    enum {
 1297       *        change_cipher_spec(20), alert(21), handshake(22),
 1298       *        application_data(23), (255)
 1299       *    } ContentType;
 1300       *
 1301       *    struct {
 1302       *        ContentType type;
 1303       *        ProtocolVersion version;
 1304       *        uint16 length;
 1305       *        opaque fragment[TLSPlaintext.length];
 1306       *    } TLSPlaintext;
 1307       */
 1308      guint32 record_length;
 1309      guint16 version;
 1310      guint8 content_type;
 1311      guint8 next_byte;
 1312      proto_tree *ti;
 1313      proto_tree *ssl_record_tree;
 1314      SslAssociation* association;
 1315      guint32 available_bytes;
 1316      ti = NULL;
 1317      ssl_record_tree = NULL;
 1318      available_bytes = 0;
 1319   
 1320[+]     available_bytes = tvb_length_remaining(tvb, offset);
 1321   
 1322      /* TLS 1.0/1.1 just ignores unknown records - RFC 2246 chapter 6. The TLS Record Protocol */
 1323      if ((*conv_version==SSL_VER_TLS || *conv_version==SSL_VER_TLSv1DOT1 || *conv_version==SSL_VER_TLSv1DOT2) &&
 1324          (available_bytes >=1 ) && !ssl_is_valid_content_type(tvb_get_guint8(tvb, offset))) {
 1325        proto_tree_add_text(tree, tvb, offset, available_bytes, "Ignored Unknown Record");
 1326        if (check_col(pinfo->cinfo, COL_INFO))
 1327            col_append_str(pinfo->cinfo, COL_INFO, "Ignored Unknown Record");
 1328        if (check_col(pinfo->cinfo, COL_PROTOCOL))
 1329            col_set_str(pinfo->cinfo, COL_PROTOCOL, ssl_version_short_names[*conv_version]);
 1330        return offset + available_bytes;
 1331      }
 1332   
 1333     /*
 1334       * Can we do reassembly?
 1335       */
 1336      if (ssl_desegment && pinfo->can_desegment) {
 1337          /*
 1338           * Yes - is the record header split across segment boundaries?
 1339           */
 1340          if (available_bytes < 5) {
 1341              /*
 1342               * Yes.  Tell the TCP dissector where the data for this
 1343               * message starts in the data it handed us, and how many 
 1344               * more bytes we need, and return.
 1345               */
 1346              pinfo->desegment_offset = offset;
 1347              pinfo->desegment_len = 5 - available_bytes;
 1348              *need_desegmentation = TRUE;
 1349              return offset;
 1350          }
 1351      }
 1352   
 1353      /*
 1354       * Get the record layer fields of interest 
 1355       */
 1356[+]     content_type  = tvb_get_guint8(tvb, offset);
 1357      version       = tvb_get_ntohs(tvb, offset + 1);
 1358      record_length = tvb_get_ntohs(tvb, offset + 3);
 1359   
 1360[+]     if (ssl_is_valid_content_type(content_type)) {
 1361   
 1362          /*
 1363           * Can we do reassembly?
 1364           */
 1365          if (ssl_desegment && pinfo->can_desegment) {
 1366              /*
 1367               * Yes - is the record split across segment boundaries?
 1368               */
 1369              if (available_bytes < record_length + 5) {
 1370                  /*
 1371                   * Yes.  Tell the TCP dissector where the data for this
 1372                   * message starts in the data it handed us, and how many 
 1373                   * more bytes we need, and return.
 1374                   */
 1375                  pinfo->desegment_offset = offset;
 1376
1399
Show [ Lines 1376 to 1399 omitted. ]
 1400          {
 1401              col_set_str(pinfo->cinfo, COL_PROTOCOL,
 1402                          ssl_version_short_names[*conv_version]);
 1403          }
 1404          return offset + 5 + record_length;
 1405      }
 1406   
 1407      /*
 1408       * If building a protocol tree, fill in record layer part of tree 
 1409       */
 1410      if (tree)
 1411      {
 1412   
 1413          /* add the record layer subtree header */
 1414          tvb_ensure_bytes_exist(tvb, offset, 5 + record_length);
 1415          ti = proto_tree_add_item(tree, hf_ssl_record, tvb,
 1416[+]                                  offset, 5 + record_length, 0);
 1417          ssl_record_tree = proto_item_add_subtree(ti, ett_ssl_record);
 1418   
 1419          /* show the one-byte content type */
 1420          proto_tree_add_item(ssl_record_tree, hf_ssl_record_content_type,
 1421                              tvb, offset, 1, 0);
 1422          offset++;
 1423   
 1424          /* add the version */
 1425          proto_tree_add_item(ssl_record_tree, hf_ssl_record_version, tvb,
 1426                              offset, 2, FALSE);
 1427          offset += 2;
 1428   
 1429          /* add the length */
 1430          proto_tree_add_uint(ssl_record_tree, hf_ssl_record_length, tvb,
 1431                              offset, 2, record_length);
 1432          offset += 2;    /* move past length field itself */
 1433      }
 1434      else 
 1435      {
 1436          /* if no protocol tree, then just skip over those fields */
 1437          offset += 5;
 1438      }
 1439   
 1440   
 1441      /*
 1442       * if we don't already have a version set for this conversation,
 1443       * but this message's version is authoritative (i.e., it's
 1444       * not client_hello, then save the version to to conversation 
 1445       * structure and print the column version
 1446       */
 1447      next_byte = tvb_get_guint8(tvb, offset);
 1448      if (*conv_version == SSL_VER_UNKNOWN 
 1449          && ssl_is_authoritative_version_message(content_type, next_byte))
 1450      {
 1451          if (version == SSLV3_VERSION)
 1452          {
 1453              *conv_version = SSL_VER_SSLv3;
 1454              if (ssl) {
 1455                  ssl->version_netorder = version;
 1456                  ssl->state |= SSL_VERSION;
 1457                  ssl_debug_printf("dissect_ssl3_record found version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
 1458              }
 1459
1484
Show [ Lines 1459 to 1484 omitted. ]
 1485   
 1486              *conv_version = SSL_VER_TLSv1DOT2;
 1487              if (ssl) {
 1488                  ssl->version_netorder = version;
 1489                  ssl->state |= SSL_VERSION;
 1490                  ssl_debug_printf("dissect_ssl3_record found version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
 1491              }
 1492              /*ssl_set_conv_version(pinfo, ssl->version);*/
 1493          }
 1494      }
 1495[+]     if (check_col(pinfo->cinfo, COL_PROTOCOL))
 1496      {
 1497              col_set_str(pinfo->cinfo, COL_PROTOCOL,
 1498                          ssl_version_short_names[*conv_version]);
 1499      }
 1500   
 1501      /*
 1502       * now dissect the next layer 
 1503       */
 1504      ssl_debug_printf("dissect_ssl3_record: content_type %d\n",content_type);
 1505   
 1506      /* PAOLO try to decrypt each record (we must keep ciphers "in sync")
 1507       * store plain text only for app data */
 1508   
 1509      switch (content_type) {
 1510      case SSL_ID_CHG_CIPHER_SPEC:
 1511          ssl_debug_printf("dissect_ssl3_change_cipher_spec\n");
 1512          if (check_col(pinfo->cinfo, COL_INFO))
 1513              col_append_str(pinfo->cinfo, COL_INFO, "Change Cipher Spec");
 1514          dissect_ssl3_change_cipher_spec(tvb, ssl_record_tree,
 1515                                          offset, conv_version, content_type);
 1516          if (ssl) ssl_change_cipher(ssl, ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype == PT_TCP));
 1517          break;
 1518      case SSL_ID_ALERT:
 1519      {
 1520          tvbuff_t* decrypted;
 1521   
 1522          if (ssl&&decrypt_ssl3_record(tvb, pinfo, offset,
 1523                  record_length, content_type, ssl, FALSE))
 1524            ssl_add_record_info(proto_ssl, pinfo, ssl_decrypted_data.data,
 1525                    ssl_decrypted_data_avail, offset);
 1526   
 1527          /* try to retrieve and use decrypted alert record, if any. */
 1528          decrypted = ssl_get_record_info(proto_ssl, pinfo, offset);
 1529          if (decrypted)
 1530            dissect_ssl3_alert(decrypted, pinfo, ssl_record_tree, 0, conv_version);
 1531          else 
 1532            dissect_ssl3_alert(tvb, pinfo, ssl_record_tree, offset, conv_version);
 1533          break;
 1534      }
 1535      case SSL_ID_HANDSHAKE:
 1536      {
 1537          tvbuff_t* decrypted;
 1538   
 1539          /* try to decrypt handshake record, if possible. Store decrypted
 1540           * record for later usage. The offset is used as 'key' to identify
 1541           * this record in the packet (we can have multiple handshake records 
 1542           * in the same frame) */
 1543          if (ssl && decrypt_ssl3_record(tvb, pinfo, offset,
 1544                  record_length, content_type, ssl, FALSE))
 1545              ssl_add_record_info(proto_ssl, pinfo, ssl_decrypted_data.data,
 1546                  ssl_decrypted_data_avail, offset);
 1547   
 1548          /* try to retrieve and use decrypted handshake record, if any. */
 1549[+]         decrypted = ssl_get_record_info(proto_ssl, pinfo, offset);
 1550          if (decrypted) {
 1551              /* add desegmented data to the data source list */
 1552              add_new_data_source(pinfo, decrypted, "Decrypted SSL record");
 1553              dissect_ssl3_handshake(decrypted, pinfo, ssl_record_tree, 0,
 1554                   decrypted->length, conv_version, ssl, content_type);
 1555          } else {
 1556              dissect_ssl3_handshake(tvb, pinfo, ssl_record_tree, offset,
 1557[+]                                record_length, conv_version, ssl, content_type);
expand/collapse

dissect_ssl3_handshake

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ssl.c)expand/collapse
Show more  
 1705  dissect_ssl3_handshake(tvbuff_t *tvb, packet_info *pinfo,
 1706                         proto_tree *tree, guint32 offset,
 1707                         guint32 record_length, guint *conv_version,
 1708                         SslDecryptSession* ssl, guint8 content_type)
 1709  {
 1710      /*     struct {
 1711       *         HandshakeType msg_type;
 1712       *         uint24 length;
 1713       *         select (HandshakeType) {
 1714       *             case hello_request:       HelloRequest;
 1715       *             case client_hello:        ClientHello;
 1716       *             case server_hello:        ServerHello;
 1717       *             case certificate:         Certificate;
 1718       *             case server_key_exchange: ServerKeyExchange;
 1719       *             case certificate_request: CertificateRequest;
 1720       *             case server_hello_done:   ServerHelloDone;
 1721       *             case certificate_verify:  CertificateVerify;
 1722       *             case client_key_exchange: ClientKeyExchange;
 1723       *             case finished:            Finished;
 1724       *         } body;
 1725       *     } Handshake;
 1726       */
 1727      proto_tree *ti;
 1728      proto_tree *ssl_hand_tree;
 1729      const gchar *msg_type_str;
 1730      guint8 msg_type;
 1731      guint32 length;
 1732      gboolean first_iteration;
 1733      ti = NULL;
 1734      ssl_hand_tree = NULL;
 1735      msg_type_str = NULL;
 1736      first_iteration = TRUE;
 1737   
 1738      /* just as there can be multiple records per packet, there 
 1739       * can be multiple messages per record as long as they have 
 1740       * the same content type
 1741       *
 1742       * we really only care about this for handshake messages 
 1743       */
 1744   
 1745      /* set record_length to the max offset */
 1746      record_length += offset;
 1747      while (offset < record_length)
 1748      {
 1749          msg_type = tvb_get_guint8(tvb, offset);
 1750          length   = tvb_get_ntoh24(tvb, offset + 1);
 1751   
 1752          /* Check the length in the handshake message. Assume it's an 
 1753           * encrypted handshake message if the message would pass
 1754           * the record_length boundary. This is a workaround for the
 1755           * situation where the first octet of the encrypted handshake 
 1756           * message is actually a known handshake message type.
 1757           */
 1758          if (offset + length <= record_length)
 1759              msg_type_str = match_strval(msg_type, ssl_31_handshake_type);
 1760          else 
 1761              msg_type_str = NULL;
 1762   
 1763          ssl_debug_printf("dissect_ssl3_handshake iteration %d type %d offset %d length %d "
 1764              "bytes, remaining %d \n", first_iteration, msg_type, offset, length, record_length);
 1765          if (!msg_type_str && !first_iteration)
 1766          {
 1767              /* only dissect / report messages if they're
 1768               * either the first message in this record 
 1769               * or they're a valid message type
 1770               */
 1771              return;
 1772          }
 1773   
 1774          /* on second and later iterations, add comma to info col */
 1775          if (!first_iteration)
 1776          {
 1777              if (check_col(pinfo->cinfo, COL_INFO))
 1778                  col_append_str(pinfo->cinfo, COL_INFO, ", ");
 1779          }
 1780   
 1781          /*
 1782           * Update our info string
 1783           */
 1784[+]         if (check_col(pinfo->cinfo, COL_INFO))
 1785              col_append_str(pinfo->cinfo, COL_INFO, (msg_type_str != NULL)
 1786                              ? msg_type_str : "Encrypted Handshake Message");
 1787   
 1788          if (tree)
 1789          {
 1790              /* set the label text on the record layer expanding node */
 1791              if (first_iteration)
 1792              {
 1793                  proto_item_set_text(tree, "%s Record Layer: %s Protocol: %s",
 1794                                      ssl_version_short_names[*conv_version],
 1795                                      val_to_str(content_type, ssl_31_content_type, "unknown"),
 1796                                      (msg_type_str!=NULL) ? msg_type_str :
 1797                                          "Encrypted Handshake Message");
Show more  
Show more  




Change Warning 3000.35592 : Buffer Overrun

Because they are very similar, this warning shares annotations with warning 3000.35593.

Priority:
State:
Finding:
Owner:
Note: