cdg: Fix assertion failure while typefinding with too short file

thread '<unnamed>' panicked at 'assertion failed: step != 0', ...

Don't iterate with zero step size.
This commit is contained in:
Seungha Yang 2020-10-04 20:44:44 +09:00
parent 5cba2b002b
commit 6559287bea

View file

@ -60,6 +60,11 @@ fn compute_probability(typefind: &mut TypeFind) -> TypeFindProbability {
.unwrap_or(TYPEFIND_SEARCH_WINDOW as u64 * NB_WINDOWS);
let step = len / NB_WINDOWS;
// Too short file
if step == 0 {
return TypeFindProbability::None;
}
for offset in (0..len).step_by(step as usize) {
let proba = match cdg_packets_ratio(typefind, offset as i64, TYPEFIND_SEARCH_WINDOW) {
0..=5 => TypeFindProbability::None,