Convert asserts into explicit checks

An assert checking whether the bit depth of a FLAC file was valid
was triggered by fuzzing. This assert is converted to a explicit
check.

Similarly, an assert was triggered with a file of sample rate 0
when trying to add seekpoints spaced with seconds.
This commit is contained in:
Martijn van Beurden 2023-03-17 21:53:50 +01:00
parent b5c763d908
commit 5b145aff12
2 changed files with 5 additions and 3 deletions

View File

@ -444,8 +444,11 @@ FLAC__bool do_shorthand_operation__add_replay_gain(char **filenames, unsigned nu
flac_fprintf(stderr, "%s: ERROR: # of channels (%u) is not supported, must be 1 or 2\n", filenames[i], channels);
return false;
}
if(bits_per_sample < FLAC__MIN_BITS_PER_SAMPLE || bits_per_sample > FLAC__MAX_BITS_PER_SAMPLE) {
flac_fprintf(stderr, "%s: ERROR: resolution (%u) is not supported, must be between %u and %u\n", filenames[i], bits_per_sample, FLAC__MIN_BITS_PER_SAMPLE, FLAC__MAX_BITS_PER_SAMPLE);
return false;
}
}
FLAC__ASSERT(bits_per_sample >= FLAC__MIN_BITS_PER_SAMPLE && bits_per_sample <= FLAC__MAX_BITS_PER_SAMPLE);
if(!grabbag__replaygain_init(sample_rate)) {
FLAC__ASSERT(0);

View File

@ -61,8 +61,7 @@ FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec
}
}
else if(q[-1] == 's') { /* -S #s */
if(total_samples_to_encode > 0) { /* we can only do these if we know the number of samples to encode up front */
FLAC__ASSERT(sample_rate > 0);
if(total_samples_to_encode > 0 && sample_rate > 0) { /* we can only do these if we know the number of samples and sample rate to encode up front */
if(0 != spec_has_real_points)
*spec_has_real_points = true;
if(!only_explicit_placeholders) {