[libdvdnav-devel] ifo_read: use info_length as a size_t

Jean-Baptiste Kempf git at videolan.org
Sun Dec 29 19:25:25 CET 2013


libdvdread | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Dec 29 19:13:27 2013 +0100| [af599d51be9f568610fb59362c373fe0918173f5] | committer: Jean-Baptiste Kempf

ifo_read: use info_length as a size_t

This makes sense since it is used as a malloc' size.
And add a check in case it would have been negative

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

 src/ifo_read.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/ifo_read.c b/src/ifo_read.c
index 776d67d..0ba5eed 100644
--- a/src/ifo_read.c
+++ b/src/ifo_read.c
@@ -1633,7 +1633,7 @@ int ifoRead_C_ADT(ifo_handle_t *ifofile) {
 
 static int ifoRead_C_ADT_internal(ifo_handle_t *ifofile,
                                   c_adt_t *c_adt, unsigned int sector) {
-  int i, info_length;
+  size_t i, info_length;
 
   if(!DVDFileSeek_(ifofile->file, sector * DVD_BLOCK_LEN))
     return 0;
@@ -1644,6 +1644,9 @@ static int ifoRead_C_ADT_internal(ifo_handle_t *ifofile,
   B2N_16(c_adt->nr_of_vobs);
   B2N_32(c_adt->last_byte);
 
+  if(c_adt->last_byte + 1 < C_ADT_SIZE)
+    return 0;
+
   info_length = c_adt->last_byte + 1 - C_ADT_SIZE;
 
   CHECK_ZERO(c_adt->zero_1);



More information about the libdvdnav-devel mailing list