diff mbox series

[15/90] connection: Check service network index for validity.

Message ID 20231206235056.322578-16-gerickson@nuovations.com (mailing list archive)
State Not Applicable, archived
Headers show
Series Add Gateway Low-priority Default Routes for Non-default Services | expand

Commit Message

Grant Erickson Dec. 6, 2023, 11:49 p.m. UTC
From: Grant Erickson <erick205@umn.edu>

In '__connman_connection_gateway_add', the network interface index is
retrieved from the 'service' parameter; however, it is not checked for
validity. Since the index will go on and later populate the gateway
data, via 'add_gateway, ensure that the index is valid. If it is not,
return -EINVAL.
---
 src/connection.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/src/connection.c b/src/connection.c
index e6a6ea42dc59..d645078d85ee 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -1845,6 +1845,8 @@  int __connman_connection_gateway_add(struct connman_service *service,
 		return -EINVAL;
 
 	index = __connman_service_get_index(service);
+	if (index < 0)
+		return -EINVAL;
 
 	interface = connman_inet_ifname(index);