aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/mp2t.c
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2012-03-05 08:30:39 +0000
committerAnders Broman <anders.broman@ericsson.com>2012-03-05 08:30:39 +0000
commit4db442ab904dd3929270f1a5a603f024d9bd08dc (patch)
treeb1102b8ff95841790f938f415955b36a9b375514 /wiretap/mp2t.c
parent26f694ddee7cac0e8929ef2f213548f05049ce77 (diff)
From Martin Kaiser:
wiretap mpeg2 ts: more thorough check for sync byte. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6908 svn path=/trunk/; revision=41349
Diffstat (limited to 'wiretap/mp2t.c')
-rw-r--r--wiretap/mp2t.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c
index b9fccec9ec..c797699859 100644
--- a/wiretap/mp2t.c
+++ b/wiretap/mp2t.c
@@ -153,6 +153,19 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
if (-1 == file_seek(wth->fh, first, SEEK_SET, err)) {
return -1;
}
+ /* read the first 10 packets and make sure they all start with a sync byte */
+ for (i = 0; i < 10; i++) {
+ bytes_read = file_read(buffer, sizeof(buffer), wth->fh);
+ if (bytes_read < 0)
+ return -1; /* read error */
+ if (bytes_read < (int)sizeof(buffer))
+ break; /* file has < 10 packets, that's ok if we're still in sync */
+ if (buffer[0] != MP2T_SYNC_BYTE)
+ return 0; /* not a valid mpeg2 ts */
+ }
+ if (-1 == file_seek(wth->fh, first, SEEK_SET, err)) {
+ return -1;
+ }
wth->file_type = WTAP_FILE_MPEG_2_TS;
wth->file_encap = WTAP_ENCAP_MPEG_2_TS;