Thread (3 messages) flat view 3 messages, 2 authors, 2014-08-26

[PATCHv3 1/2] android/client: Fix incorrect data parsing

From: Marcin Kraglak <hidden>
Date: 2014-08-26 10:20:53
Subsystem: the rest · Maintainer: Linus Torvalds

Use fill_buffer function in processing write_characteristic
and send_indication functions.
---
 android/client/if-gatt.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index 8154bfd..1d8def2 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -1191,11 +1191,12 @@ static void write_characteristic_p(int argc, const char **argv)
 		return;
 	}
 
-	/* len in chars */
-	len = strlen(argv[6]);
-	scan_field(argv[6], len, value, sizeof(value));
-	/* len in bytes converted from ascii chars */
-	len = (len + 1) / 2;
+	if (argv[6][0] != '0' || (argv[6][1] != 'X' && argv[6][1] != 'x')) {
+		haltest_error("Value must be hex string");
+		return;
+	}
+
+	len = fill_buffer(argv[6] + 2, value, sizeof(value));
 
 	/* auth_req */
 	if (argc > 7)
@@ -1791,8 +1792,13 @@ static void gatts_send_indication_p(int argc, const char *argv[])
 	confirm = atoi(argv[5]);
 
 	if (argc > 6) {
-		len = strlen(argv[6]);
-		scan_field(argv[6], len, (uint8_t *) data, sizeof(data));
+		if (argv[6][0] != '0' ||
+				(argv[6][1] != 'X' && argv[6][1] != 'x')) {
+			haltest_error("Value must be hex string");
+			return;
+		}
+
+		len = fill_buffer(argv[6] + 2, (uint8_t *) data, sizeof(data));
 	}
 
 	EXEC(if_gatt->server->send_indication, server_if, attr_handle, conn_id,
-- 
1.9.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help