diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-11-11 13:02:26 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-11-11 13:02:26 +0000 |
commit | 8784da27bffd8d89df6a7f2b7a021ebffb6b93f4 (patch) | |
tree | 1562a2338a355405228db7d81b19b0f87dd880e3 | |
parent | 587b7b4ef87b561e4f303b98b4e254f32eefa152 (diff) | |
parent | 477e6aca1eed0a6f2f07d0ece21b084730ceb493 (diff) | |
download | flac-android12-mainline-networkstack-release.tar.gz |
Snap for 7905862 from 477e6aca1eed0a6f2f07d0ece21b084730ceb493 to mainline-networking-releaseandroid-mainline-12.0.0_r99android-mainline-12.0.0_r77android-mainline-12.0.0_r70android-mainline-12.0.0_r63android-mainline-12.0.0_r59android-mainline-12.0.0_r49android-mainline-12.0.0_r122android-mainline-12.0.0_r100android12-mainline-networkstack-release
Change-Id: Ic8cf0cb1bbfa068615739b3040ad0ce69630e85f
-rw-r--r-- | src/libFLAC/stream_decoder.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index 67070177..51a438cc 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -2996,7 +2996,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound, lower_bound_sample, upper_bound_sample, this_frame_sample; FLAC__int64 pos = -1; int i; - uint32_t approx_bytes_per_frame; + FLAC__int64 approx_bytes_per_frame; FLAC__bool first_seek = true; const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder); const uint32_t min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize; @@ -3041,6 +3041,12 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s upper_bound = stream_length; upper_bound_sample = total_samples > 0 ? total_samples : target_sample /*estimate it*/; + /* seeking beyond the end of the stream */ + if(target_sample > upper_bound_sample) { + decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; + return false; + } + /* * Now we refine the bounds if we have a seektable with * suitable points. Note that according to the spec they @@ -3169,7 +3175,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s return false; } /* our last move backwards wasn't big enough, try again */ - approx_bytes_per_frame = approx_bytes_per_frame? approx_bytes_per_frame * 2 : 16; + approx_bytes_per_frame = (approx_bytes_per_frame > (upper_bound - lower_bound)) ? (upper_bound - lower_bound) : approx_bytes_per_frame ? approx_bytes_per_frame * 2 : 16; continue; } /* allow one seek over upper bound, so we can get a correct upper_bound_sample for streams with unknown total_samples */ |