[UTC][capi-media-vision][NonACR] return when GetValueForTCTSetting() is false 58/285658/1
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 16 Dec 2022 05:32:07 +0000 (14:32 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Fri, 16 Dec 2022 05:39:47 +0000 (05:39 +0000)
It tries to allocat memory even if GetValueForTCTSetting() is
false so that related variable are null. Then, it causes SIGSEGV.
To prevent that, check GetValueForTCTSetting() first then check features
if GetValueForTCTSetting() is true. Otherwise, just return startup
function().

Change-Id: Iff5e87e654579908fb87599216842685f64993af
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
src/utc/capi-media-vision/utc-mv_3d.c
src/utc/capi-media-vision/utc-mv_barcode.c
src/utc/capi-media-vision/utc-mv_face.c
src/utc/capi-media-vision/utc-mv_image.c
src/utc/capi-media-vision/utc-mv_surveillance.c

index 03900ab69a79eae683bc538d71f712afb7e2688e..85fe5f186b2a569ea7a52a4d90b898ccfafe2616 100755 (executable)
@@ -214,14 +214,6 @@ void utc_capi_media_vision_3d_startup(void)
 {
     printf("capi-media-vision 3d tests STARTUP is launched\n");
 
-    system_info_get_platform_bool(MV3D_DEPTH_FEATURE, &gIsMv3dDepthSupported);
-    system_info_get_platform_bool(MV3D_POINTCLOUD_FEATURE, &gIsMv3dPointCloudSupported);
-
-    if (gIsMv3dDepthSupported || gIsMv3dPointCloudSupported)
-        gIsMv3dSupported = true;
-    else
-        gIsMv3dSupported = false;
-
     char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
     if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) {
         PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\\n", __LINE__, API_NAMESPACE, pszValue);
@@ -231,8 +223,17 @@ void utc_capi_media_vision_3d_startup(void)
 
     } else {
         PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
+        return;
     }
 
+    system_info_get_platform_bool(MV3D_DEPTH_FEATURE, &gIsMv3dDepthSupported);
+    system_info_get_platform_bool(MV3D_POINTCLOUD_FEATURE, &gIsMv3dPointCloudSupported);
+
+    if (gIsMv3dDepthSupported || gIsMv3dPointCloudSupported)
+        gIsMv3dSupported = true;
+    else
+        gIsMv3dSupported = false;
+
     gStartupError = mv_create_engine_config(&gEngineConfigHandle);
     if (MEDIA_VISION_ERROR_NONE != gStartupError) {
         gEngineConfigHandle = NULL;
index 79fd668d276eea265bb3839bdabb95aed110c066..13ed175b29a117db464afc54c4d97d696f783d88 100755 (executable)
@@ -619,12 +619,6 @@ void utc_capi_media_vision_barcode_startup(void)
 {
     printf("capi-media-vision tests STARTUP is launched\n");
 
-    bool isBarcodeDetectionSupported = false;
-    bool isBarcodeGenerationSupported = false;
-
-    system_info_get_platform_bool("http://tizen.org/feature/vision.barcode_detection", &isBarcodeDetectionSupported);
-    system_info_get_platform_bool("http://tizen.org/feature/vision.barcode_generation", &isBarcodeGenerationSupported);
-
     char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
     if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) {
         PRINT_UTC_LOG("[Line: %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received = %s\\n", __LINE__, API_NAMESPACE, pszValue);
@@ -637,8 +631,14 @@ void utc_capi_media_vision_barcode_startup(void)
         snprintf(test_data_path, path_size, "%s/data", pszValue);
     } else {
         PRINT_UTC_LOG("[Line: %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
+        return;
     }
 
+    bool isBarcodeDetectionSupported = false;
+    bool isBarcodeGenerationSupported = false;
+
+    system_info_get_platform_bool("http://tizen.org/feature/vision.barcode_detection", &isBarcodeDetectionSupported);
+    system_info_get_platform_bool("http://tizen.org/feature/vision.barcode_generation", &isBarcodeGenerationSupported);
 
     if (isBarcodeDetectionSupported || isBarcodeGenerationSupported)
         isVisionSupported = true;
index 597cbbb4d2d7deebd5c56296b8a6c1944c358175..301e83d7df2e25c155ef6b9242cdb8b68c90e43d 100755 (executable)
@@ -220,15 +220,6 @@ void utc_capi_media_vision_face_startup(void)
 {
     printf("capi-media-vision mv_face tests STARTUP is launched\n");
 
-    bool isFaceRecognitionSupported = false;
-
-    system_info_get_platform_bool("http://tizen.org/feature/vision.face_recognition", &isFaceRecognitionSupported);
-
-    if (isFaceRecognitionSupported)
-        isVisionSupported = true;
-    else
-        isVisionSupported = false;
-
     char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
     if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) {
         PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\\n", __LINE__, API_NAMESPACE, pszValue);
@@ -258,7 +249,18 @@ void utc_capi_media_vision_face_startup(void)
         snprintf(path_to_rec_model, strlen(pszValue)+strlen("/res/res/model/test_rec_model")+1, "%s/res/res/model/test_rec_model", pszValue);
     } else {
         PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
+        return;
     }
+
+    bool isFaceRecognitionSupported = false;
+
+    system_info_get_platform_bool("http://tizen.org/feature/vision.face_recognition", &isFaceRecognitionSupported);
+
+    if (isFaceRecognitionSupported)
+        isVisionSupported = true;
+    else
+        isVisionSupported = false;
+
     printf("capi-media-vision mv_face tests STARTUP is completed\n");
 }
 
index 1bdb50e5565fbb0c825c7322a9e1de67056ad78b..1feaf17e0f2e9cc4ef5005dd5d9d25a4235885f5 100755 (executable)
@@ -164,14 +164,6 @@ void utc_capi_media_vision_image_startup(void)
 {
     printf("capi-media-vision mv_image tests STARTUP is launched\n");
 
-    bool isImageRecognitionSupported = false;
-    system_info_get_platform_bool("http://tizen.org/feature/vision.image_recognition", &isImageRecognitionSupported);
-
-    if (isImageRecognitionSupported)
-        isVisionSupported = true;
-    else
-        isVisionSupported = false;
-    
     char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
     if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) {
         PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\\n", __LINE__, API_NAMESPACE, pszValue);
@@ -188,8 +180,17 @@ void utc_capi_media_vision_image_startup(void)
         snprintf(pInternalDataPath, strlen(pszValue)+strlen("/data")+1, "%s/data", pszValue);
     } else {
         PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
+        return;
     }
 
+    bool isImageRecognitionSupported = false;
+    system_info_get_platform_bool("http://tizen.org/feature/vision.image_recognition", &isImageRecognitionSupported);
+
+    if (isImageRecognitionSupported)
+        isVisionSupported = true;
+    else
+        isVisionSupported = false;
+
     gStartupError = mv_image_tracking_model_create(&g_tracking_model);
     if (MEDIA_VISION_ERROR_NONE != gStartupError) {
         g_tracking_model = NULL;
index ce636afdfd54a8e1c1e5af77b734367cb6c9d449..4651cdc85129ecfb3457fc3c8397f8e8b3f76d64 100755 (executable)
@@ -51,19 +51,8 @@ static char* pInternalStoragePath=NULL;
  */
 void utc_capi_media_vision_surveillance_startup(void)
 {
-       bool isFaceRecognitionSupported = false;
-       bool isImageRecognitionSupported = false;
-
        printf("capi-media-vision surveillance tests STARTUP is launched\n");
 
-       system_info_get_platform_bool("http://tizen.org/feature/vision.face_recognition", &isFaceRecognitionSupported);
-       system_info_get_platform_bool("http://tizen.org/feature/vision.image_recognition", &isImageRecognitionSupported);
-
-       if (isFaceRecognitionSupported || isImageRecognitionSupported)
-               isVisionSupported = true;
-       else
-               isVisionSupported = false;
-
        char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
        if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) {
                PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\\n", __LINE__, API_NAMESPACE, pszValue);
@@ -71,8 +60,20 @@ void utc_capi_media_vision_surveillance_startup(void)
                snprintf(pInternalStoragePath, strlen(pszValue)+1, "%s", pszValue);
        } else {
                PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
+               return;
        }
 
+       bool isFaceRecognitionSupported = false;
+       bool isImageRecognitionSupported = false;
+
+       system_info_get_platform_bool("http://tizen.org/feature/vision.face_recognition", &isFaceRecognitionSupported);
+       system_info_get_platform_bool("http://tizen.org/feature/vision.image_recognition", &isImageRecognitionSupported);
+
+       if (isFaceRecognitionSupported || isImageRecognitionSupported)
+               isVisionSupported = true;
+       else
+               isVisionSupported = false;
+
        gStartupError = MEDIA_VISION_ERROR_NONE;
 
        gStartupError = mv_surveillance_event_trigger_create(