summaryrefslogtreecommitdiffstats
path: root/libhb/stream.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2012-01-14 18:08:44 +0000
committerjstebbins <[email protected]>2012-01-14 18:08:44 +0000
commite5d16119f267eca2d9e294541aa6e9307c021d19 (patch)
tree25772fec0d21b0408414c7c56d0b6bfcaebd7cd1 /libhb/stream.c
parent19f6610d3d3bc0a4144a7612294a47bfcf307371 (diff)
Improve mpeg-ps detection
Make mis-detects less likely by checking all the marker bits in the pack header. This makes it much less likely that we will be spoofed by data that looks like a pack header. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4406 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/stream.c')
-rw-r--r--libhb/stream.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libhb/stream.c b/libhb/stream.c
index 2bd0e2573..69ba920f7 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -464,11 +464,31 @@ static int check_ps_sc(const uint8_t *buf)
int mark = buf[4] >> 4;
if ( mark == 0x02 )
{
+ // Check other marker bits to make it less likely
+ // that we are being spoofed.
+ if( ( buf[4] & 0xf1 ) != 0x21 ||
+ ( buf[6] & 0x01 ) != 0x01 ||
+ ( buf[8] & 0x01 ) != 0x01 ||
+ ( buf[9] & 0x80 ) != 0x80 ||
+ ( buf[11] & 0x01 ) != 0x01 )
+ {
+ return 0;
+ }
// mpeg-1 pack header
pos = 12; // skip over the PACK
}
else
{
+ // Check other marker bits to make it less likely
+ // that we are being spoofed.
+ if( ( buf[4] & 0xC4 ) != 0x44 ||
+ ( buf[6] & 0x04 ) != 0x04 ||
+ ( buf[8] & 0x04 ) != 0x04 ||
+ ( buf[9] & 0x01 ) != 0x01 ||
+ ( buf[12] & 0x03 ) != 0x03 )
+ {
+ return 0;
+ }
// mpeg-2 pack header
pos = 14 + ( buf[13] & 0x7 ); // skip over the PACK
}