changeset 20487:5c953a55103f

1000l: fixed broken handling of the adaption field - part 2 The value of c must be between 0 and 183 inclusive; is c is 0 I can't skip c-1 bytes!
author nicodvb
date Sun, 29 Oct 2006 10:55:02 +0000
parents 0cc36dd385ec
children f485fb548bf3
files libmpdemux/demux_ts.c
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_ts.c	Sun Oct 29 10:33:49 2006 +0000
+++ b/libmpdemux/demux_ts.c	Sun Oct 29 10:55:02 2006 +0000
@@ -2633,14 +2633,24 @@
 			int c;
 			c = stream_read_char(stream);
 			buf_size--;
+			if(c < 0 || c > 183)	//broken from the stream layer or invalid
+			{
+				stream_skip(stream, buf_size-1+junk);
+				continue;
+			}
+			
+			//c==0 is allowed!
+			if(c > 0)
+			{
 			rap_flag = (stream_read_char(stream) & 0x40) >> 6;
 			buf_size--;
 
-			c = min(c-1, buf_size);
+			c--;
 			stream_skip(stream, c);
 			buf_size -= c;
 			if(buf_size == 0)
 				continue;
+			}
 		}
 		
 		if(bad)