This is similar to what wcmSerialValidate() does but only does the skipping of an already started invalid packet. At this point we don't have the packet length defined yet so this is just an early exit path.
Signed-off-by: Peter Hutterer <[email protected]> --- src/wcmISDV4.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/wcmISDV4.c b/src/wcmISDV4.c index 0c8b0a8..c71f0c7 100644 --- a/src/wcmISDV4.c +++ b/src/wcmISDV4.c @@ -71,6 +71,24 @@ static int wcmWait(int t) } /***************************************************************************** + * wcmSkipInvalidBytes - returns the number of bytes to skip if the first + * byte of data does not denote a valid header byte. + * The ISDV protocol requires that the first byte of a new packet has the + * HEADER_BIT set and subsequent packets do not. + ****************************************************************************/ +static int wcmSkipInvalidBytes(const unsigned char* data, int len) +{ + int n = 0; + + while(n < len && !(data[n] & HEADER_BIT)) + n++; + + return n; +} + + + +/***************************************************************************** * wcmSerialValidate -- validates serial packet; returns 0 on success, * positive number of bytes to skip on error. ****************************************************************************/ @@ -398,6 +416,9 @@ static int isdv4Parse(LocalDevicePtr local, const unsigned char* data, int len) DBG(10, common, "\n"); + if ((n = wcmSkipInvalidBytes(data, len)) > 0) + return n; + /* choose wcmPktLength if it is not an out-prox event */ if (data[0]) common->wcmPktLength = WACOM_PKGLEN_TPCPEN; -- 1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Linuxwacom-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
