summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2020-06-05 10:02:33 -0600
committerJohn Stebbins <[email protected]>2020-06-05 10:06:37 -0600
commit9527541672654db9921352d8a5621d705450a2b6 (patch)
treef940a2d6f435f43c00203d2aff72d2545f09456e
parent5dd453c5f6971aba5b63c4a26efc38f2459f64e2 (diff)
bd: fix out of array bounds access
When 4k support was added to libbluray, the possible video format values overran our 'rank' array. (cherry picked from commit 75bae14a8b182a5d60f1096b444fc5ce74dfa415)
-rw-r--r--libhb/bd.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libhb/bd.c b/libhb/bd.c
index 1cd2cff99..fecd7ae90 100644
--- a/libhb/bd.c
+++ b/libhb/bd.c
@@ -727,9 +727,9 @@ int hb_bd_main_feature( hb_bd_t * d, hb_list_t * list_title )
int longest = 0;
int ii;
uint64_t longest_duration = 0;
- int highest_rank = 0;
+ int highest_rank = 0, rank;
int most_chapters = 0;
- int rank[8] = {0, 1, 3, 2, 6, 5, 7, 4};
+ int ranks[9] = {0, 1, 3, 2, 6, 5, 7, 4, 8};
BLURAY_TITLE_INFO * ti;
for ( ii = 0; ii < hb_list_count( list_title ); ii++ )
@@ -741,16 +741,21 @@ int hb_bd_main_feature( hb_bd_t * d, hb_list_t * list_title )
BLURAY_STREAM_INFO * bdvideo = &ti->clips[0].video_streams[0];
if ( title->duration > longest_duration * 0.7 && bdvideo->format < 8 )
{
- if (highest_rank < rank[bdvideo->format] ||
+ rank = 0;
+ if (bdvideo->format <= 8)
+ {
+ rank = ranks[bdvideo->format];
+ }
+ if (highest_rank < rank ||
( title->duration > longest_duration &&
- highest_rank == rank[bdvideo->format]))
+ highest_rank == rank))
{
longest = title->index;
longest_duration = title->duration;
- highest_rank = rank[bdvideo->format];
+ highest_rank = rank;
most_chapters = ti->chapter_count;
}
- else if (highest_rank == rank[bdvideo->format] &&
+ else if (highest_rank == rank &&
title->duration == longest_duration &&
ti->chapter_count > most_chapters)
{