[mythtv] Tiny hdtv buffer overrun patch

sbower at cisco.com sbower at cisco.com
Wed Oct 15 15:23:06 EDT 2003


Howdy,

Doug's patch from the other day has a potential buffer overrun in
hdtvrecorder.cpp; here's a little fix.

  Steve.
-------------- next part --------------
Index: libs/libmythtv/hdtvrecorder.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/hdtvrecorder.cpp,v
retrieving revision 1.6
diff -u -r1.6 hdtvrecorder.cpp
--- libs/libmythtv/hdtvrecorder.cpp     13 Oct 2003 21:23:30 -0000      1.6
+++ libs/libmythtv/hdtvrecorder.cpp     15 Oct 2003 17:42:39 -0000
@@ -395,6 +395,7 @@
     while (pos + 187 < len) // while we have a whole packet left
     {
         // Find sync byte (0x47)
+        resync_count = 0;
         while (buffer[pos] != 0x47)
         {
             pos++;
@@ -406,9 +407,11 @@
             }
         }
         if (resync_count)
+        {
             cerr << "Skipped " << resync_count << " bytes to resync" << endl;
-        
-        resync_count = 0;
+            // if (pos+187 >= len) cerr << "Past end of buffer" << endl;
+            continue;           // Perform length test again
+        }
         ts_packets++;
         packet_start_pos = pos;
         packet_end_pos = pos + 188;


More information about the mythtv-dev mailing list