Skip to content

Commit a28589f

Browse files
committed
Set bounds to replaygain synthesis gain
The fuzzer found that with a large enough gain in dB, a gain variable would become inf, leading to overflows. This commit adds a check for absurd gain values.
1 parent db7b34c commit a28589f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/flac/decode.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,15 @@ void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMet
17971797
}
17981798
decoder_session->replaygain.apply = false;
17991799
}
1800+
/* Bounds just to make sure calculations don't overflow */
1801+
else if(gain > 90 || gain < -90) {
1802+
flac__utils_printf(stderr, 1, "%s: WARNING: can't apply ReplayGain, found gain value doesn't make sense\n", decoder_session->inbasefilename);
1803+
if(decoder_session->treat_warnings_as_errors) {
1804+
decoder_session->abort_flag = true;
1805+
return;
1806+
}
1807+
decoder_session->replaygain.apply = false;
1808+
}
18001809
else {
18011810
const char *ls[] = { "no", "peak", "hard" };
18021811
const char *ns[] = { "no", "low", "medium", "high" };

0 commit comments

Comments
 (0)