diff mbox series

[v3,02/60] service: Sanity check the 'type' param in '__connman_service_wispr_start'.

Message ID 20231221223508.2365510-3-gerickson@nuovations.com (mailing list archive)
State Accepted, archived
Headers show
Series Complete 'continuous' Online Check Mode Implementation. | expand

Commit Message

Grant Erickson Dec. 21, 2023, 10:34 p.m. UTC
This adds sanity checking for the 'type' parameter in
'__connman_service_wispr_start'. In addition, it adds an explicit
conditional test for the 'CONNMAN_IPCONFIG_TYPE_IPV6'.

Both of these ensure that neither 'CONNMAN_IPCONFIG_TYPE_ALL' or
'CONNMAN_IPCONFIG_TYPE_UNKNOWN' trigger a WISPr start but, instead,
error out.
---
 src/service.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/service.c b/src/service.c
index 7af0d4a5f60c..e5cd6fcd306a 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2430,10 +2430,18 @@  int __connman_service_wispr_start(struct connman_service *service,
 	if (!service)
 		return -EINVAL;
 
+	switch (type) {
+	case CONNMAN_IPCONFIG_TYPE_IPV4:
+	case CONNMAN_IPCONFIG_TYPE_IPV6:
+		break;
+	default:
+		return -EINVAL;
+	}
+
 	if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
 		service->online_check_state_ipv4.interval =
 					online_check_initial_interval;
-	else
+	else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
 		service->online_check_state_ipv6.interval =
 					online_check_initial_interval;