Diff between 28559cf267bd178d3f79de66a213042afa86b70b and fdd99da31ea0e23d340f4bbd040bd63b35bc4c3a

Changed Files

File Additions Deletions Status
android/client/if-gatt.c +11 -1 modified

Full Patch

diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index c8352b5..0ceffa6 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -114,11 +114,17 @@ const btgatt_interface_t *if_gatt = NULL;
 
 #define GET_VERIFY_HEX_STRING(n, v, l) \
 	do { \
+		int ll;\
 		if (n[0] != '0' || (n[1] != 'X' && n[1] != 'x')) { \
 			haltest_error("Value must be hex string\n"); \
 			return; \
 		} \
-		l = fill_buffer(n + 2, (uint8_t *) v, sizeof(v)); \
+		ll = fill_buffer(n + 2, (uint8_t *) v, sizeof(v)); \
+		if (ll < 0) { \
+			haltest_error("Value must be byte hex string\n"); \
+			return; \
+		} \
+		l = ll; \
 	} while (0)
 
 /* Gatt uses little endian uuid */
@@ -803,6 +809,10 @@ static int fill_buffer(const char *str, uint8_t *out, int out_size)
 
 	str_len = strlen(str);
 
+	/* Hex string must be byte format */
+	if (str_len % 2)
+		return -1;
+
 	for (i = 0, j = 0; i < out_size && j < str_len; i++, j++) {
 		c = str[j];