[PATCH 2/2] android/client: Check if hex string is byte format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Data strings should be byte format.
---
 android/client/if-gatt.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index c8352b5..5cae7e8 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -803,6 +803,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 != 0)
+		return -1;
+
 	for (i = 0, j = 0; i < out_size && j < str_len; i++, j++) {
 		c = str[j];
 
@@ -1201,6 +1205,10 @@ static void write_characteristic_p(int argc, const char **argv)
 	}
 
 	GET_VERIFY_HEX_STRING(argv[6], value, len);
+	if (len < 0) {
+		haltest_error("Value must be byte hex string\n");
+		return;
+	}
 
 	/* auth_req */
 	if (argc > 7)
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux