Author: duncan
Date: Sat Dec 23 18:07:04 2006
New Revision: 2286

Modified:
   trunk/metadata/src/video/mkv.py

Log:
When the inbuf is too small the calculation of the id fails;
added a length check to prevent this error.


Modified: trunk/metadata/src/video/mkv.py
==============================================================================
--- trunk/metadata/src/video/mkv.py     (original)
+++ trunk/metadata/src/video/mkv.py     Sat Dec 23 18:07:04 2006
@@ -170,19 +170,27 @@
 
 
     def compute_id(self, inbuf):
+        if len(inbuf) < 1:
+            return 0
         first = ord(inbuf[0])
         self.id_len = 0
         if first & 0x80:
             self.id_len = 1
             self.entity_id = first
         elif first & 0x40:
+            if len(inbuf) < 2:
+                return 0
             self.id_len = 2
             self.entity_id = ord(inbuf[0])<<8 | ord(inbuf[1])
         elif first & 0x20:
+            if len(inbuf) < 3:
+                return 0
             self.id_len = 3
             self.entity_id = (ord(inbuf[0])<<16) | (ord(inbuf[1])<<8) | \
                              (ord(inbuf[2]))
         elif first & 0x10:
+            if len(inbuf) < 4:
+                return 0
             self.id_len = 4
             self.entity_id = (ord(inbuf[0])<<24) | (ord(inbuf[1])<<16) | \
                              (ord(inbuf[2])<<8) | (ord(inbuf[3]))

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to