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
This commit is contained in:
Anders Broman 2012-03-05 08:30:39 +00:00
parent 26f694ddee
commit 4db442ab90
1 changed files with 13 additions and 0 deletions

View File

@ -150,6 +150,19 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
return 0;
}
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;
}