aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/btsnoop.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-01-22 00:26:36 +0000
committerGuy Harris <guy@alum.mit.edu>2014-01-22 00:26:36 +0000
commit90d7c5f59b574e254bc1bb70aaaf12372fe97cc3 (patch)
tree7bc8e69b7cc459b8dfef190d1b33a7cb092a7bf3 /wiretap/btsnoop.c
parent5c825d6a364d83dace7b6c682aa47678e89df79b (diff)
Don't write out packets that have a "captured length" bigger than we're
willing to read or that's bigger than will fit in the file format; instead, report an error. For the "I can't write a packet of that type in that file type" error, report the file type in question. svn path=/trunk/; revision=54882
Diffstat (limited to 'wiretap/btsnoop.c')
-rw-r--r--wiretap/btsnoop.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c
index 9fc2cb06f4..3c67f84198 100644
--- a/wiretap/btsnoop.c
+++ b/wiretap/btsnoop.c
@@ -333,6 +333,15 @@ static gboolean btsnoop_dump_h1(wtap_dumper *wdh,
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
struct btsnooprec_hdr rec_hdr;
+ /*
+ * Don't write out anything bigger than we can read.
+ * (This will also fail on a caplen of 0, as it should.)
+ */
+ if (phdr->caplen-1 > WTAP_MAX_PACKET_SIZE) {
+ *err = WTAP_ERR_PACKET_TOO_LARGE;
+ return FALSE;
+ }
+
if (!btsnoop_dump_partial_rec_hdr(wdh, phdr, pseudo_header, pd, err, &rec_hdr))
return FALSE;
@@ -362,6 +371,12 @@ static gboolean btsnoop_dump_h4(wtap_dumper *wdh,
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
struct btsnooprec_hdr rec_hdr;
+ /* Don't write out anything bigger than we can read. */
+ if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+ *err = WTAP_ERR_PACKET_TOO_LARGE;
+ return FALSE;
+ }
+
if (!btsnoop_dump_partial_rec_hdr(wdh, phdr, pseudo_header, pd, err, &rec_hdr))
return FALSE;