#define NETCONFIG_NETWORK_PATH "/net/netconfig/network"
#define NETCONFIG_NETWORK_INTERFACE "net.netconfig.network"
+#define VPNSVC_IP4_MIN_STRING_LEN 7
+#define VPNSVC_IP4_MAX_STRING_LEN 15
+
#define VPNSVC_IP4_STRING_LEN 16
#define VPNSVC_VPN_IFACE_NAME_LEN 16
#define VPNSVC_SESSION_STRING_LEN 32
return false;
}
+static bool _vpn_check_ip_address_validity(const char *addr)
+{
+ if(strlen(addr) < VPNSVC_IP4_MIN_STRING_LEN
+ || strlen(addr) > VPNSVC_IP4_MAX_STRING_LEN)
+ return false;
+
+ return true;
+}
+
static void _vpnsvc_init_vpnsvc_tun_s(vpnsvc_tun_s **s)
{
LOGD(" tun_s: %p", s);
LOGE("handle is a NULL"); //LCOV_EXCL_LINE
return VPNSVC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+
tun_s = (vpnsvc_tun_s*)handle;
+ if (!_vpn_check_ip_address_validity(tun_s->local_ip))
+ return VPNSVC_ERROR_INVALID_PARAMETER;
+
+ if (!_vpn_check_ip_address_validity(tun_s->remote_ip))
+ return VPNSVC_ERROR_INVALID_PARAMETER;
+
op = _vpnsvc_invoke_dbus_method(tun_s->connection,
NETCONFIG_SERVICE_NAME,
NETCONFIG_VPNSVC_PATH,