Skip to content

Commit f4117f8

Browse files
authored
wavpack: Fix infinite loop when reading broken files (#1304)
A crafted file can have blockSamples set to 0 and a blockSize so big that when adding 8 it overflows and offset is 0 so it goes back to the same position and loops forever
1 parent cf86f20 commit f4117f8

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

taglib/wavpack/wavpackproperties.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,16 @@ void WavPack::Properties::read(File *file, offset_t streamLength)
260260
const unsigned int flags = data.toUInt(24, false);
261261
unsigned int smplRate = sampleRates[(flags & SRATE_MASK) >> SRATE_LSB];
262262

263-
if(!blockSamples) { // ignore blocks with no samples
264-
offset += blockSize + 8;
265-
continue;
266-
}
267-
268263
if(blockSize < 24 || blockSize > 1048576) {
269264
debug("WavPack::Properties::read() -- Invalid block header found.");
270265
break;
271266
}
272267

268+
if(!blockSamples) { // ignore blocks with no samples
269+
offset += blockSize + 8;
270+
continue;
271+
}
272+
273273
// For non-standard sample rates or DSD audio files, we must read and parse the block
274274
// to actually determine the sample rate.
275275

0 commit comments

Comments
 (0)