lkml.org 
[lkml]   [2008]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] usbmon binary format reader loses synchronization
Hello Pete,

there's a bug in the usbmon binary reader: When using read() to fetch
the packets and a packet's data is partially read the next read call
will once again return up to len_cap bytes of data. The b_read counter
is not regarded when determining the remaining chunk size.

When dumping USB data with "cat /dev/usbmon0 > usbmon.trace" while
reading from a USB storage device and analyzing the dump file
afterwards it will get out of sync after a couple of packets.

Cheers,
Ingo

Signed-off-by: Ingo van Lil <inguin@gmx.de>
---
diff -urN a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
--- a/drivers/usb/mon/mon_bin.c 2008-07-13 23:51:29.000000000 +0200
+++ b/drivers/usb/mon/mon_bin.c 2008-11-13 11:44:03.000000000 +0100
@@ -681,7 +681,7 @@
}

if (rp->b_read >= sizeof(struct mon_bin_hdr)) {
- step_len = min(nbytes, (size_t)ep->len_cap);
+ step_len = min(nbytes, sizeof(struct mon_bin_hdr) + (size_t)ep->len_cap - rp->b_read);
offset = rp->b_out + PKT_SIZE;
offset += rp->b_read - sizeof(struct mon_bin_hdr);
if (offset >= rp->b_size)

\
 
 \ /
  Last update: 2008-11-13 14:03    [W:0.035 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site