[libbluray-devel] index_parse: check for EOF

hpi1 git at videolan.org
Mon Jun 26 15:25:33 CEST 2017


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Jun 26 16:01:46 2017 +0300| [f788989c1bce1895f38ee547be40845e010440ec] | committer: hpi1

index_parse: check for EOF

Fixes long delay with corrupt input.

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=f788989c1bce1895f38ee547be40845e010440ec
---

 src/libbluray/bdnav/index_parse.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/libbluray/bdnav/index_parse.c b/src/libbluray/bdnav/index_parse.c
index 6a0f5a01..54767219 100644
--- a/src/libbluray/bdnav/index_parse.c
+++ b/src/libbluray/bdnav/index_parse.c
@@ -114,6 +114,11 @@ static int _parse_index(BITSTREAM *bs, INDX_ROOT *index)
         return 0;
     }
 
+    if (bs_avail(bs)/(12*8) < index->num_titles) {
+        BD_DEBUG(DBG_HDMV|DBG_CRIT, "index.bdmv: unexpected EOF\n");
+        return 0;
+    }
+
     for (i = 0; i < index->num_titles; i++) {
 
         index->titles[i].object_type = bs_read(bs, 2);



More information about the libbluray-devel mailing list