summaryrefslogtreecommitdiffstats
path: root/libhb
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:04 -0600
commit75bae14a8b182a5d60f1096b444fc5ce74dfa415 (patch)
tree09fa18e09b3d426da47128cfde63561f38f18612 /libhb
parent39934c127ad0ba1388ed7aa487656b6681f371c8 (diff)
bd: fix out of array bounds access
When 4k support was added to libbluray, the possible video format values overran our 'rank' array.
Diffstat (limited to 'libhb')
-rw-r--r--libhb/bd.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libhb/bd.c b/libhb/bd.c
index 72e1c9fb5..c60e503c4 100644
--- a/libhb/bd.c
+++ b/libhb/bd.c
@@ -729,9 +729,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++ )
@@ -743,16 +743,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)
{