Retry a short read instead of skipping past it
The previous commit bounded the crack scan inspection by the bytes actually read, which stopped it examining stale buffer bytes from an earlier batch. But the cursor still advanced by the REQUESTED count, so those sectors were skipped outright — trading "scans the wrong data" for "silently scans less than it thinks", on exactly the damaged media where a title key is hardest to find. The cursor now advances by what was read, so the next iteration resumes where the read stopped. Floored at one sector so a source returning Ok(0) cannot spin. Found by reading the fix again rather than by the next audit round.
This commit is contained in:
+10
-1
@@ -277,6 +277,13 @@ fn crack_key_scan(
|
|||||||
}
|
}
|
||||||
let n = (ext.sector_count - i).min(batch);
|
let n = (ext.sector_count - i).min(batch);
|
||||||
let want = n as usize * 2048;
|
let want = n as usize * 2048;
|
||||||
|
// How far the cursor advances. Set from the bytes actually READ on
|
||||||
|
// the Ok path so a short read is RETRIED from where it stopped
|
||||||
|
// rather than skipped: bounding only the inspection (which is what
|
||||||
|
// stops stale buffer bytes being scanned) would otherwise leave
|
||||||
|
// those sectors unexamined, quietly shrinking the crack's coverage
|
||||||
|
// on exactly the damaged media where a key is hardest to find.
|
||||||
|
let mut advance = n;
|
||||||
match reader.read_sectors(ext.start_lba + i, n as u16, &mut buf[..want], true) {
|
match reader.read_sectors(ext.start_lba + i, n as u16, &mut buf[..want], true) {
|
||||||
Ok(got) => {
|
Ok(got) => {
|
||||||
// A readable batch: the gate is open — reset the locked run.
|
// A readable batch: the gate is open — reset the locked run.
|
||||||
@@ -292,6 +299,8 @@ fn crack_key_scan(
|
|||||||
// installed and its wrong descrambles are only partly caught
|
// installed and its wrong descrambles are only partly caught
|
||||||
// by the per-sector crib.
|
// by the per-sector crib.
|
||||||
let usable = (got / 2048).min(n as usize);
|
let usable = (got / 2048).min(n as usize);
|
||||||
|
// At least one, so a source returning Ok(0) cannot spin here.
|
||||||
|
advance = (usable as u32).max(1);
|
||||||
for s in 0..usable {
|
for s in 0..usable {
|
||||||
tried += 1;
|
tried += 1;
|
||||||
let sect = &buf[s * 2048..(s + 1) * 2048];
|
let sect = &buf[s * 2048..(s + 1) * 2048];
|
||||||
@@ -330,7 +339,7 @@ fn crack_key_scan(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i += n;
|
i += advance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user