(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-memcache.c) |
| |
| 1389 | | | memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, |
| 1390 | | | const guchar *line, const guchar *lineend, guint8 opcode) |
| 1391 | | | { |
| 1392 | | | const guchar *next_token; |
| 1393 | | | int tokenlen; |
| 1394 | | | |
| 1395 | | | guint16 flags; |
| 1396 | | | guint32 expiration; |
| 1397 | | | guint32 bytes; |
| 1398 | | | guint64 cas; |
| 1399 | | | gchar response_chars[21]; |
| 1400 | | | |
| 1401 | | | |
| 1402 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1403 | | | if (tokenlen == 0) { |
| 1404 | | | return -1; |
| 1405 | | | } |
| 1406 | | | proto_tree_add_item (tree, hf_command, tvb, offset, tokenlen, FALSE); |
| 1407 | | | offset += (int) (next_token - line); |
| 1408 | | | line = next_token; |
| 1409 | | | |
| 1410 | | | switch (opcode) { |
| 1411 | | | |
| 1412 | | | case OP_SET: |
| 1413 | | | case OP_ADD: |
| 1414 | | | case OP_REPLACE: |
| 1415 | | | case OP_APPEND: |
| 1416 | | | case OP_PREPEND: |
| 1417 | | | case OP_CAS: |
| 1418 | | | |
| 1419 | | | |
| 1420 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1421 | | | if (tokenlen == 0) { |
| 1422 | | | return -1; |
| 1423 | | | } |
| 1424 | | | |
| 1425 | | | dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, TRUE); |
| 1426 | | | offset += (int) (next_token - line); |
| 1427 | | | line = next_token; |
| 1428 | | | |
| 1429 | | | |
| 1430 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1431 | | | if (tokenlen == 0 || tokenlen > 5) { |
| 1432 | | | return -1; |
| 1433 | | | } |
| 1434 | | | memcpy (response_chars, line, tokenlen); |
| 1435 | | | response_chars[tokenlen] = '\0'; |
| 1436 | | | |
| 1437 | | | flags = (guint16) strtoul (response_chars, NULL, 10); |
| 1438 | | | proto_tree_add_uint (tree, hf_flags, tvb, offset, tokenlen, flags); |
| 1439 | | | |
| 1440 | | | offset += (int) (next_token - line); |
| 1441 | | | line = next_token; |
| 1442 | | | |
| 1443 | | | |
| 1444 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1445 | | | if (tokenlen == 0 || tokenlen > 10) { |
| 1446 | | | return -1; |
| 1447 | | | } |
| 1448 | | | memcpy (response_chars, line, tokenlen); |
| 1449 | | | response_chars[tokenlen] = '\0'; |
| 1450 | | | |
| 1451 | | | expiration = (guint32) strtoul (response_chars, NULL, 10); |
| 1452 | | | proto_tree_add_uint (tree, hf_expiration, tvb, offset, tokenlen, expiration); |
| 1453 | | | |
| 1454 | | | offset += (int) (next_token - line); |
| 1455 | | | line = next_token; |
| 1456 | | | |
| 1457 | | | |
| 1458 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1459 | | | if (tokenlen == 0 || tokenlen > 10) { |
| 1460 | | | return -1; |
| 1461 | | | } |
| 1462 | | | memcpy (response_chars, line, tokenlen); |
| 1463 | | | response_chars[tokenlen] = '\0'; |
| 1464 | | | |
| 1465 | | | bytes = (guint32) strtoul (response_chars, NULL, 10); |
| 1466 | | | proto_tree_add_uint (tree, hf_value_length, tvb, offset, tokenlen, bytes); |
| 1467 | | | |
| 1468 | | | offset += (int) (next_token - line); |
| 1469 | | | line = next_token; |
| 1470 | | | |
| 1471 | | | |
| 1472 | | | if (opcode == OP_CAS) { |
| 1473 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1474 | | | if (tokenlen == 0 || tokenlen > 20) { |
| 1475 | | | return -1; |
| 1476 | | | } |
| 1477 | | | memcpy (response_chars, line, tokenlen); |
| 1478 | | | response_chars[tokenlen] = '\0'; |
| 1479 | | | |
| 1480 | | | cas = (guint64) strtoul (response_chars, NULL, 10); |
| 1481 | | | proto_tree_add_uint64 (tree, hf_cas, tvb, offset, tokenlen, cas); |
| 1482 | | | |
| 1483 | | | offset += (int) (next_token - line); |
| 1484 | | | line = next_token; |
| 1485 | | | } |
| 1486 | | | |
| 1487 | | | |
| 1488 | | | |
| 1489 | | | |
| 1490 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1491 | | | if (tokenlen != 0) { |
| 1492 | | | if (tokenlen == 7 && strncmp (line, "noreply", 7) == 0) { |
| 1493 | | | proto_tree_add_item (tree, hf_noreply, tvb, offset, tokenlen, FALSE); |
| 1494 | | | } |
| 1495 | | | offset += (int) (next_token - line); |
| 1496 | | | line = next_token; |
| 1497 | | | } |
| 1498 | | | |
| 1499 | | | offset += 2 ; |
| 1500 | | | |
| 1501 | | | offset = content_data_dissector (tvb, pinfo, tree, offset, bytes, opcode); |
| 1502 | | | if (offset == -1) { |
| 1503 | | | return offset; |
| 1504 | | | } |
| 1505 | | | break; |
| 1506 | | | |
| 1507 | | | case OP_INCREMENT: |
| 1508 | | | case OP_DECREMENT: |
| 1509 | | | |
| 1510 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1511 | | | if (tokenlen == 0) { |
| 1512 | | | return -1; |
| 1513 | | | } |
| 1514 | | | dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, TRUE); |
| 1515 | | | offset += (int) (next_token - line); |
| 1516 | | | line = next_token; |
| 1517 | | | |
| 1518 | | | |
| 1519 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1520 | | | if (tokenlen == 0) { |
| 1521 | | | return -1; |
| 1522 | | | } |
| 1523 | | | proto_tree_add_item (tree, hf_value, tvb, offset, tokenlen, FALSE); |
| 1524 | | | offset += (int) (next_token - line); |
| 1525 | | | line = next_token; |
| 1526 | | | |
| 1527 | | | |
| 1528 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1529 | | | if (tokenlen == 0) { |
| 1530 | | | return offset; |
| 1531 | | | } |
| 1532 | | | if (tokenlen == 7 && strncmp (line, "noreply", 7) == 0) { |
| 1533 | | | proto_tree_add_item (tree, hf_noreply, tvb, offset, tokenlen, FALSE); |
| 1534 | | | offset += (int) (next_token - line); |
| 1535 | | | line = next_token; |
| 1536 | | | } else { |
| 1537 | | | return -1; |
| 1538 | | | } |
| 1539 | | | |
| 1540 | | | |
| 1541 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1542 | | | if (tokenlen == 0) { |
| 1543 | | | return offset; |
| 1544 | | | } else { |
| 1545 | | | |
| 1546 | | | return -1; |
| 1547 | | | } |
| 1548 | | | break; |
Unreachable Control Flow
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 1549 | | | |
| 1550 | | | case OP_DELETE: |
| 1551 | | | |
| 1552 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1553 | | | if (tokenlen == 0) { |
| 1554 | | | return -1; |
| 1555 | | | } |
| 1556 | | | |
| 1557 | | | dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, TRUE); |
| 1558 | | | offset += (int) (next_token - line); |
| 1559 | | | line = next_token; |
| 1560 | | | |
| 1561 | | | |
| 1562 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1563 | | | if (tokenlen == 0) { |
| 1564 | | | return offset; |
| 1565 | | | } |
| 1566 | | | if (tokenlen <= 10) { |
| 1567 | | | if (tokenlen == 7 && strncmp (line, "noreply", 7) == 0) { |
| 1568 | | | |
| 1569 | | | proto_tree_add_item (tree, hf_noreply, tvb, offset, tokenlen, FALSE); |
| 1570 | | | } else { |
| 1571 | | | |
| 1572 | | | memcpy (response_chars, line, tokenlen); |
| 1573 | | | response_chars[tokenlen] = '\0'; |
| 1574 | | | |
| 1575 | | | expiration = (guint32) strtoul (response_chars, NULL, 10); |
| 1576 | | | proto_tree_add_uint (tree, hf_expiration, tvb, offset, tokenlen, expiration); |
| 1577 | | | } |
| 1578 | | | offset += (int) (next_token - line); |
| 1579 | | | line = next_token; |
| 1580 | | | } else { |
| 1581 | | | return -1; |
| 1582 | | | } |
| 1583 | | | |
| 1584 | | | |
| 1585 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1586 | | | if (tokenlen == 0) { |
| 1587 | | | return offset; |
| 1588 | | | } else { |
| 1589 | | | |
| 1590 | | | return -1; |
| 1591 | | | } |
| 1592 | | | break; |
| 1593 | | | |
| 1594 | | | case OP_GET: |
| 1595 | | | case OP_GETS: |
| 1596 | | | |
| 1597 | | | |
| 1598 | | | |
| 1599 | | | |
| 1600 | | | while (tokenlen != 0) { |
| 1601 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1602 | | | if (tokenlen == 0) { |
| 1603 | | | return offset; |
| 1604 | | | } |
| 1605 | | | dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, TRUE); |
| 1606 | | | offset += (int) (next_token - line); |
| 1607 | | | line = next_token; |
| 1608 | | | } |
| 1609 | | | break; |
| 1610 | | | |
| 1611 | | | case OP_STAT: |
| 1612 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1613 | | | if (tokenlen == 0) { |
| 1614 | | | return offset; |
| 1615 | | | } else { |
| 1616 | | | proto_tree_add_item (tree, hf_subcommand, tvb, offset, tokenlen, FALSE); |
| 1617 | | | offset += (int) (next_token - line); |
| 1618 | | | line = next_token; |
| 1619 | | | } |
| 1620 | | | |
| 1621 | | | |
| 1622 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1623 | | | if (tokenlen == 0) { |
| 1624 | | | return offset; |
| 1625 | | | } else { |
| 1626 | | | |
| 1627 | | | return -1; |
| 1628 | | | } |
| 1629 | | | break; |
| 1630 | | | |
| 1631 | | | case OP_FLUSH: |
| 1632 | | | |
| 1633 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1634 | | | if (tokenlen == 0) { |
| 1635 | | | return offset; |
| 1636 | | | } |
| 1637 | | | if (tokenlen <= 10) { |
| 1638 | | | if (tokenlen == 7 && strncmp (line, "noreply", 7) == 0) { |
| 1639 | | | |
| 1640 | | | proto_tree_add_item (tree, hf_noreply, tvb, offset, tokenlen, FALSE); |
| 1641 | | | } else { |
| 1642 | | | |
| 1643 | | | memcpy (response_chars, line, tokenlen); |
| 1644 | | | response_chars[tokenlen] = '\0'; |
| 1645 | | | |
| 1646 | | | expiration = (guint32) strtoul (response_chars, NULL, 10); |
| 1647 | | | proto_tree_add_uint (tree, hf_expiration, tvb, offset, tokenlen, expiration); |
| 1648 | | | } |
| 1649 | | | offset += (int) (next_token - line); |
| 1650 | | | line = next_token; |
| 1651 | | | } else { |
| 1652 | | | return -1; |
| 1653 | | | } |
| 1654 | | | |
| 1655 | | | |
| 1656 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1657 | | | if (tokenlen == 0) { |
| 1658 | | | return offset; |
| 1659 | | | } |
| 1660 | | | if (tokenlen == 7 && strncmp (line, "noreply", 7) == 0) { |
| 1661 | | | |
| 1662 | | | proto_tree_add_item (tree, hf_noreply, tvb, offset, tokenlen, FALSE); |
| 1663 | | | offset += (int) (next_token - line); |
| 1664 | | | line = next_token; |
| 1665 | | | } else { |
| 1666 | | | return -1; |
| 1667 | | | } |
| 1668 | | | break; |
| 1669 | | | |
| 1670 | | | case OP_VERBOSE: |
| 1671 | | | |
| 1672 | | | break; |
| 1673 | | | |
| 1674 | | | case OP_VERSION: |
| 1675 | | | case OP_QUIT: |
| 1676 | | | |
| 1677 | | | tokenlen = get_token_len (line, lineend, &next_token); |
| 1678 | | | if (tokenlen == 0) { |
| 1679 | | | return offset; |
| 1680 | | | } else { |
| 1681 | | | |
| 1682 | | | return -1; |
| 1683 | | | } |
| 1684 | | | |
| 1685 | | | default: |
| 1686 | | | |
| 1687 | | | break; |
| 1688 | | | } |
| 1689 | | | |
| 1690 | | | return offset; |
| 1691 | | | } |
| |