summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeslie Zhai <[email protected]>2017-08-14 16:21:18 +0800
committerLeslie Zhai <[email protected]>2017-08-14 16:21:18 +0800
commitd50a0c30b582aa2fc5cfccea4b87a70adc2d5d81 (patch)
tree324dcaba1dc05a2ee17edca1914b4d619a9def0c
parent96540735dbcc3189812e6d46cf7d147f006e5654 (diff)
Fix wrong comparison if there are no descriptors.
A patch by Thomas Schmitt! Testplan by Mark: cdrskin -V dev=/dev/sr0 2>&1 >/tmp/cdrskin_scsi_log CCBUG: 382941
-rw-r--r--libk3bdevice/k3bdevice.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/libk3bdevice/k3bdevice.cpp b/libk3bdevice/k3bdevice.cpp
index f531642..e256564 100644
--- a/libk3bdevice/k3bdevice.cpp
+++ b/libk3bdevice/k3bdevice.cpp
@@ -3228,12 +3228,11 @@ QList<int> K3b::Device::Device::determineSupportedWriteSpeeds() const
bool K3b::Device::Device::getSupportedWriteSpeedsVia2A(QList<int>& list, MediaType mediaType) const
{
- UByteArray data;
+ UByteArray/* QVarLengthArray<unsigned char> */ data;
if (modeSense(data, 0x2A)) {
mm_cap_page_2A* mm = (mm_cap_page_2A*)&data[8];
- // FIXME: why > 32? not bigger than 64?
- if (data.size() > 32) {
+ if (data.size() > 32 + 8/* pageLen? */) {
// we have descriptors
unsigned int numDesc = from2Byte(mm->num_wr_speed_des);
@@ -3241,7 +3240,6 @@ bool K3b::Device::Device::getSupportedWriteSpeedsVia2A(QList<int>& list, MediaTy
// the descriptors rather than the number of descriptors
// Ensure number of descriptors claimed actually fits in the data
// returned by the mode sense command.
- // FIXME: why 32 - 8? not minus 9 or 10?
if (static_cast<int>(numDesc) > ((data.size() - 32 - 8) / 4))
numDesc = (data.size() - 32 - 8) / 4;
@@ -3251,8 +3249,6 @@ bool K3b::Device::Device::getSupportedWriteSpeedsVia2A(QList<int>& list, MediaTy
<< ": Number of supported write speeds via 2A: "
<< numDesc << endl;
- // FIXME: if numDesc is wrong, wr[i] might be out-of-bounds, then
- // from2Byte failed to work.
for (unsigned int i = 0; i < numDesc; ++i) {
int s = (int)from2Byte(wr[i].wr_speed_supp);
//