webrtc_source : add missing parameter check code 93/254993/8
authorhj kim <backto.kim@samsung.com>
Thu, 11 Mar 2021 07:15:19 +0000 (16:15 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 18 Mar 2021 08:11:30 +0000 (17:11 +0900)
plus, fix wrong return value

[Version] 0.1.129
[Issue Type] Improvement

Change-Id: I70cc965b7074047802edb0cabd36ff73f21b2f37

packaging/capi-media-webrtc.spec
src/webrtc.c
src/webrtc_display.c
src/webrtc_source.c

index 79e81cfdf937e7fedbb36de75449bd7ea6411424..a0a407079049c36cdf8c3c91b491547abef9ed63 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.1.128
+Version:    0.1.129
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 031fec4ad137bbdfcda8703ab50fbe68eccbbf87..1ff9fd5c0b6a62bbbd2b64fbc03538488ac72568 100644 (file)
@@ -237,6 +237,7 @@ int webrtc_get_state(webrtc_h webrtc, webrtc_state_e *state)
        webrtc_s *_webrtc = (webrtc_s*)webrtc;
 
        RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+       RET_VAL_IF(state == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "state is NULL");
 
        g_mutex_lock(&_webrtc->mutex);
 
@@ -447,6 +448,7 @@ int webrtc_set_display(webrtc_h webrtc, unsigned int track_id, webrtc_display_ty
        RET_VAL_WITH_UNLOCK_IF(_webrtc->track_added_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex, "callback was not set");
        RET_VAL_WITH_UNLOCK_IF(!_is_owner_of_track_build_context(_webrtc, track_id), WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex,
                        "this function should be called within the track added callback");
+       RET_VAL_IF(type > WEBRTC_DISPLAY_TYPE_EVAS, WEBRTC_ERROR_INVALID_PARAMETER, "invalid display type(%d)", type);
 
        ret = _set_display_to_sink(webrtc, track_id, (unsigned int)type, (void *)display);
        if (ret == WEBRTC_ERROR_NONE)
index b760042c0bd10a1164211855fc2069fe0621fe56..04296af1995c3ab319a4099e0748e3bd55397743 100644 (file)
@@ -720,7 +720,7 @@ int _apply_display(webrtc_display_s *display)
 
        default:
                LOG_ERROR_IF_REACHED("type(%d)", display->type);
-               return WEBRTC_ERROR_INVALID_OPERATION;
+               return WEBRTC_ERROR_INVALID_PARAMETER;
        }
 
        return ret;
index 7fef0c0ebdc6381caec5e12a0b7178cd644b0bce..abe87346e764b216384005ef59fba34d2a0c4063 100644 (file)
@@ -1177,6 +1177,7 @@ int _add_media_source(webrtc_s *webrtc, webrtc_media_source_type_e type, unsigne
        RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL");
        RET_VAL_IF(source_id == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is NULL");
+       RET_VAL_IF(type > WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, WEBRTC_ERROR_INVALID_PARAMETER, "invalid source type(%d)", type);
 
        /* bin_name/source will be freed by function which is set to g_hash_table_new_full() */
        id = __get_unoccupied_id(webrtc->gst.source_slots);