[PATCH BlueZ 6/7] android: Add assertion for ID parameter in ipc_register/ipc_unregister

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

 



It is a programming error to pass a invalid ID for these functions (i.e.
the ID is statically defined on the code). Given that this ID is used
for indexing an array, adding an assertion will ensure that improper API
usage will not cause random crashes due to memory corruption.
---
 android/ipc.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/ipc.c b/android/ipc.c
index ab0f1a4..373345c 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -336,12 +336,16 @@ void ipc_send_notif(uint8_t service_id, uint8_t opcode,  uint16_t len,
 void ipc_register(uint8_t service, const struct ipc_handler *handlers,
 								uint8_t size)
 {
+	g_assert(service <= HAL_SERVICE_ID_MAX);
+
 	services[service].handler = handlers;
 	services[service].size = size;
 }
 
 void ipc_unregister(uint8_t service)
 {
+	g_assert(service <= HAL_SERVICE_ID_MAX);
+
 	services[service].handler = NULL;
 	services[service].size = 0;
 }
-- 
1.7.9.5

--
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