Limit the maximum number of input addresses 74/234374/1 accepted/tizen/unified/20200603.150236 submit/tizen/20200528.074811
authorCheoleun Moon <chleun.moon@samsung.com>
Tue, 26 May 2020 01:47:53 +0000 (10:47 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Tue, 26 May 2020 01:48:00 +0000 (10:48 +0900)
Change-Id: Id4a8051a87015afc618a3d83b11c1309f83be90b
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
include/vpn_service.h
src/capi_vpn_service.c

index e2f0f48..6cce610 100755 (executable)
@@ -165,10 +165,10 @@ int vpnsvc_write(vpnsvc_h handle, const char* data, size_t size);
  * @param[in] handle                  The VPN interface handle
  * @param[in] routes_dest_vpn_addr    Destination address of the routes, the list of allowing networks over VPN interface (e.g., VPN interface such as tun0, etc).
  * @param[in] routes_vpn_prefix       The prefix of VPN interface, netmask length (also called a prefix, e.g. 8, 16, 24, 32).
- * @param[in] num_allow_routes_vpn    The number of allowing networks over VPN interface
+ * @param[in] num_allow_routes_vpn    The number of allowing networks over VPN interface. Up to 255 addresses can be allowed.
  * @param[in] routes_dest_orig_addr   Destination address of the routes, the list of allowing networks over the original interface (e.g., original interface such as eth0, wlan0, etc).
  * @param[in] routes_orig_prefix      The prefix of Original interface, netmask length (also called a prefix, e.g. 8, 16, 24, 32).
- * @param[in] num_allow_routes_orig   The number of allowing networks over the original interface
+ * @param[in] num_allow_routes_orig   The number of allowing networks over the original interface. Up to 255addresses can be allowed.
  * @return 0 on success. otherwise, a negative error value.
  * @retval #VPNSVC_ERROR_NONE                  Success
  * @retval #VPNSVC_ERROR_INVALID_PARAMETER     Invalid parameter
index 95b087d..86b2325 100755 (executable)
@@ -30,6 +30,7 @@
 
 #define DBUS_REPLY_TIMEOUT (120 * 1000)
 #define BUF_SIZE_FOR_ERR 100
+#define MAX_NUM_ROUTES 255
 
 GVariant *op = NULL;
 
@@ -708,6 +709,12 @@ EXPORT_API int vpnsvc_block_networks(vpnsvc_h handle,
                LOGE("handle is a NULL"); //LCOV_EXCL_LINE
                return VPNSVC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
+
+       if (num_allow_routes_vpn > MAX_NUM_ROUTES || num_allow_routes_orig > MAX_NUM_ROUTES) {
+               LOGE("too many routes");
+               return VPNSVC_ERROR_INVALID_PARAMETER;
+       }
+
        tun_s = (vpnsvc_tun_s*)handle;
 
        LOGD("enter vpnsvc_block_networks");