aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-04-03 12:20:46 +0200
committerAleksander Morgado <aleksander@lanedo.com>2013-04-04 19:26:51 +0200
commit38b120c8617724ba97ac212c9e01d01c850abdc8 (patch)
treed447d614ca0092d14e96592b86bd6c4d86f307c1
parent4ea827a3a11767081d1c055d694ce644e6723cef (diff)
port-probe: don't assume the NULL bytes will be at the beginning of the response
Also report as non-AT responses if the NUL bytes are embedded within a stream of bytes which doesn't start with NUL. This e.g. applies to CnS ports from Sierra modems, which show streams like: ~\0\245y\0}^T1_0_4_0BT R372 CNSZXD00000061 2011/05/12 15:25:25\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0T1_0_4_0AP R372 CNSZXD00000061 2011/05 /12 15:25:25\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0~~ \0Tb\0T1_0_4_0AP R372 CNSZXD
-rw-r--r--src/mm-port-probe.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
index 788c1045..6c36e6ba 100644
--- a/src/mm-port-probe.c
+++ b/src/mm-port-probe.c
@@ -597,15 +597,16 @@ static gboolean
is_non_at_response (const guint8 *data, gsize len)
{
const gchar **iter;
- size_t iter_len;
- int i;
+ gsize iter_len;
+ gsize i;
/* Some devices (observed on a ZTE branded "QUALCOMM INCORPORATED" model
* "154") spew NULLs from some ports.
*/
- if ( (len >= sizeof (zerobuf))
- && (memcmp (data, zerobuf, sizeof (zerobuf)) == 0))
- return TRUE;
+ for (i = 0; (len >= sizeof (zerobuf)) && (i < len - sizeof (zerobuf)); i++) {
+ if (!memcmp (&data[i], zerobuf, sizeof (zerobuf)))
+ return TRUE;
+ }
/* Check for a well-known non-AT response. There are some ports (eg many
* Icera-based chipsets, Qualcomm Gobi devices before their firmware is