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);
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(+)