Revision 091d055b hw/ide.c

b/hw/ide.c
1715 1715
    case GPCMD_GET_CONFIGURATION:
1716 1716
        {
1717 1717
            uint32_t len;
1718
            uint8_t index = 0;
1718 1719

  
1719 1720
            /* only feature 0 is supported */
1720 1721
            if (packet[2] != 0 || packet[3] != 0) {
......
1725 1726

  
1726 1727
            /* XXX: could result in alignment problems in some architectures */
1727 1728
            max_len = ube16_to_cpu(packet + 7);
1729

  
1728 1730
            /*
1729
             * XXX: avoid overflow for io_buffer if max_len is bigger than the
1730
             *      size of that buffer (dimensioned to max number of sectors
1731
             *      to transfer at once)
1731
             * XXX: avoid overflow for io_buffer if max_len is bigger than
1732
             *      the size of that buffer (dimensioned to max number of
1733
             *      sectors to transfer at once)
1732 1734
             *
1733
             *      Only a problem if the feature/profiles grow exponentially.
1735
             *      Only a problem if the feature/profiles grow.
1734 1736
             */
1735 1737
            if (max_len > 512) /* XXX: assume 1 sector */
1736 1738
                max_len = 512;
......
1743 1745
             * XXX: fails to detect correctly DVDs with less data burned
1744 1746
             *      than what a CD can hold
1745 1747
             */
1746
            if ((s -> nb_sectors)) {
1747
                if ((s -> nb_sectors > CD_MAX_SECTORS))
1748
            if (s -> nb_sectors) {
1749
                if (s -> nb_sectors > CD_MAX_SECTORS)
1748 1750
                    cpu_to_ube16(buf + 6, MMC_PROFILE_DVD_ROM);
1749 1751
                else
1750 1752
                    cpu_to_ube16(buf + 6, MMC_PROFILE_CD_ROM);
1751 1753
            }
1752 1754

  
1753
            len = 8; /* header completed */
1754
            if (max_len > len) {
1755
                uint8_t index = 0;
1756

  
1757
                buf[10] = 0x02 | 0x01; /* persistent and current */
1758
                len += 4; /* header */
1759
                len += ide_atapi_set_profile(buf, &index, MMC_PROFILE_DVD_ROM);
1760
                len += ide_atapi_set_profile(buf, &index, MMC_PROFILE_CD_ROM);
1761
            }
1755
            buf[10] = 0x02 | 0x01; /* persistent and current */
1756
            len = 12; /* headers: 8 + 4 */
1757
            len += ide_atapi_set_profile(buf, &index, MMC_PROFILE_DVD_ROM);
1758
            len += ide_atapi_set_profile(buf, &index, MMC_PROFILE_CD_ROM);
1762 1759
            cpu_to_ube32(buf, len - 4); /* data length */
1763 1760

  
1764 1761
            ide_atapi_cmd_reply(s, len, max_len);

Also available in: Unified diff