diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2007-03-25 19:00:59 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2007-03-25 19:00:59 +0000 |
commit | 4e7a4e0b06525ec0b61d49c0a96e265863a8217f (patch) | |
tree | 4fdeada38c720e976dbef26ff1533a3c2f4a8532 /wiretap/mpeg.c | |
parent | 27f97a1dfc40935bc0fe0627acf4660c7e75bb77 (diff) | |
download | wireshark-4e7a4e0b06525ec0b61d49c0a96e265863a8217f.tar.gz |
make the mpeg_open() more conservative checking whether there's ssome magic bytes at the beginning of the file.
I added just one type of mpeg magic ("ID3") there's probably more, please add.
svn path=/trunk/; revision=21185
Diffstat (limited to 'wiretap/mpeg.c')
-rw-r--r-- | wiretap/mpeg.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c index 6a700e352b..b62281a7a6 100644 --- a/wiretap/mpeg.c +++ b/wiretap/mpeg.c @@ -250,18 +250,45 @@ mpeg_close(wtap *wth _U_) } +/* XXX We probably need more magic to open more types */ +struct _mpeg_magic { + size_t len; + gchar* match; +} magic[] = { + {3,"ID3"}, + {0,NULL} +}; + int mpeg_open(wtap *wth, int *err, gchar **err_info) { guint32 n; struct mpa mpa; - + struct _mpeg_magic* m; + char magic_buf[16]; + now.secs = time(NULL); now.nsecs = 0; t0 = (double) now.secs; + if ( file_read(magic_buf, 1, 16, wth->fh) != 16 ) { + return -1; + } else { + if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) + return -1; + } + + for (m=magic;m->match;m++) { + if (memcmp(magic_buf,m->match,m->len) == 0) + goto good_magic; + } + + return -1; + +good_magic: if (mpeg_read_header(wth, err, err_info, &n) == -1) return -1; + MPA_UNMARSHAL(&mpa, n); if (!MPA_SYNC_VALID(&mpa)) { gint64 offset; |