Fix arguments check of component port API 67/253967/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 22 Feb 2021 02:47:29 +0000 (11:47 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 22 Feb 2021 02:48:07 +0000 (11:48 +0900)
Change-Id: Ic58c14d18a2dccd870ab3e2b5381bc30948bee8e
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
component_based/port/stub.cc

index 6d6bbb54da88082b18255af474b6d68c4b953040..2e8f62c4bd057a6a22f89ee19f81115fad38673e 100644 (file)
@@ -182,7 +182,7 @@ PortWatcherStub port_watcher;
 
 extern "C" EXPORT_API int component_port_create(const char* port_name,
     component_port_h* port) {
-  if (port_name == nullptr || port == nullptr) {
+  if (port_name == nullptr || strlen(port_name) == 0 || port == nullptr) {
     _E("Invalid parameter");
     return COMPONENT_PORT_ERROR_INVALID_PARAMETER;
   }
@@ -241,7 +241,7 @@ extern "C" EXPORT_API int component_port_set_sync_request_cb(
 
 extern "C" EXPORT_API int component_port_add_privilege(component_port_h port,
     const char *privilege) {
-  if (port == nullptr || privilege == nullptr) {
+  if (port == nullptr || privilege == nullptr || strlen(privilege) == 0) {
     _E("Invalid parameter");
     return COMPONENT_PORT_ERROR_INVALID_PARAMETER;
   }
@@ -280,7 +280,8 @@ extern "C" EXPORT_API void component_port_cancel(component_port_h port) {
 
 extern "C" EXPORT_API int component_port_send(component_port_h port,
     const char *endpoint, int timeout, parcel_h request) {
-  if (port == nullptr || endpoint == nullptr || request == nullptr) {
+  if (port == nullptr || endpoint == nullptr || request == nullptr ||
+      strlen(endpoint) == 0) {
     _E("Invalid parameter");
     return COMPONENT_PORT_ERROR_INVALID_PARAMETER;
   }
@@ -306,7 +307,7 @@ extern "C" EXPORT_API int component_port_send(component_port_h port,
 extern "C" EXPORT_API int component_port_send_sync(component_port_h port,
     const char *endpoint, int timeout, parcel_h request, parcel_h *response) {
   if (port == nullptr || endpoint == nullptr || request == nullptr ||
-      response == nullptr) {
+      response == nullptr || strlen(endpoint) == 0) {
     _E("Invalid parameter");
     return COMPONENT_PORT_ERROR_INVALID_PARAMETER;
   }
@@ -338,7 +339,7 @@ extern "C" EXPORT_API int component_port_send_sync(component_port_h port,
 
 extern "C" EXPORT_API int component_port_is_running(const char* endpoint,
     bool* is_running) {
-  if (endpoint == nullptr || is_running == nullptr) {
+  if (endpoint == nullptr || is_running == nullptr || strlen(endpoint) == 0) {
     _E("Invalid parameter");
     return COMPONENT_PORT_ERROR_INVALID_PARAMETER;
   }
@@ -359,7 +360,7 @@ extern "C" EXPORT_API int component_port_watch(const char *endpoint,
     void* user_data,
     unsigned int* watcher_id) {
   if (endpoint == nullptr || appeared_cb == nullptr || vanished_cb == nullptr ||
-      watcher_id == nullptr) {
+      watcher_id == nullptr || strlen(endpoint) == 0) {
     _E("Invalid parameter");
     return COMPONENT_PORT_ERROR_INVALID_PARAMETER;
   }