Fix coverity issue - Improper use of negative value, Unchecked return value 08/174508/1 accepted/tizen/unified/20180405.064338 submit/tizen/20180404.024456
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 2 Apr 2018 11:11:50 +0000 (20:11 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 2 Apr 2018 11:11:50 +0000 (20:11 +0900)
[Version] 0.3.11
[Profile] Common
[Issue Type] Coverity
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=]

Change-Id: I6986e6bd874922945a4fc952a507d839a86251e8
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
muse/include/muse_recorder_msg.h
muse/src/muse_recorder_dispatcher.c
packaging/mmsvc-recorder.spec

index 1a02e13..08be928 100644 (file)
@@ -249,11 +249,14 @@ typedef const char* STRING;
 #define muse_recorder_msg_event(api, event, class, module) \
        do {    \
                char *__sndMsg__; \
+               int __len__; \
                __sndMsg__ = muse_core_msg_new(api, \
                        MUSE_TYPE_INT, PARAM_EVENT, event, \
                        MUSE_TYPE_INT, PARAM_EVENT_CLASS, class, \
                        0); \
-               muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               __len__ = muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               if (__len__ <= 0) \
+                       LOGE("sending message failed [%d]", __len__); \
                muse_core_msg_free(__sndMsg__); \
        } while (0)
 
@@ -269,13 +272,16 @@ typedef const char* STRING;
 #define muse_recorder_msg_event1(api, event, class, module, type, param) \
        do {    \
                char *__sndMsg__; \
+               int __len__; \
                type __value__ = (type)param; \
                __sndMsg__ = muse_core_msg_new(api, \
                        MUSE_TYPE_INT, PARAM_EVENT, event, \
                        MUSE_TYPE_INT, PARAM_EVENT_CLASS, class, \
                        MUSE_TYPE_##type, #param, __value__, \
                        0); \
-               muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               __len__ = muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               if (__len__ <= 0) \
+                       LOGE("sending message failed [%d]", __len__); \
                muse_core_msg_free(__sndMsg__); \
        } while (0)
 
@@ -292,6 +298,7 @@ typedef const char* STRING;
 #define muse_recorder_msg_event2(api, event, class, module, type1, param1, type2, param2) \
        do {    \
                char *__sndMsg__; \
+               int __len__; \
                type1 __value1__ = (type1)param1; \
                type2 __value2__ = (type2)param2; \
                __sndMsg__ = muse_core_msg_new(api, \
@@ -300,7 +307,9 @@ typedef const char* STRING;
                        MUSE_TYPE_##type1, #param1, __value1__, \
                        MUSE_TYPE_##type2, #param2, __value2__, \
                        0); \
-               muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               __len__ = muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               if (__len__ <= 0) \
+                       LOGE("sending message failed [%d]", __len__); \
                muse_core_msg_free(__sndMsg__); \
        } while (0)
 
@@ -319,6 +328,7 @@ typedef const char* STRING;
 #define muse_recorder_msg_event3(api, event, class, module, type1, param1, type2, param2, type3, param3) \
        do {    \
                char *__sndMsg__; \
+               int __len__; \
                type1 __value1__ = (type1)param1; \
                type2 __value2__ = (type2)param2; \
                type3 __value3__ = (type3)param3; \
@@ -329,7 +339,9 @@ typedef const char* STRING;
                        MUSE_TYPE_##type2, #param2, __value2__, \
                        MUSE_TYPE_##type3, #param3, __value3__, \
                        0); \
-               muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               __len__ = muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               if (__len__ <= 0) \
+                       LOGE("sending message failed [%d]", __len__); \
                muse_core_msg_free(__sndMsg__); \
        } while (0)
 
@@ -352,6 +364,7 @@ typedef const char* STRING;
 #define muse_recorder_msg_event5(api, event, class, module, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5) \
        do {    \
                char *__sndMsg__; \
+               int __len__; \
                type1 __value1__ = (type1)param1; \
                type2 __value2__ = (type2)param2; \
                type3 __value3__ = (type3)param3; \
@@ -366,7 +379,9 @@ typedef const char* STRING;
                        MUSE_TYPE_##type4, #param4, __value4__, \
                        MUSE_TYPE_##type5, #param5, __value5__, \
                        0); \
-               muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               __len__ = muse_core_msg_send(muse_server_module_get_msg_fd(module), __sndMsg__); \
+               if (__len__ <= 0) \
+                       LOGE("sending message failed [%d]", __len__); \
                muse_core_msg_free(__sndMsg__); \
        } while (0)
 
index 292855e..d9fea6d 100644 (file)
@@ -761,6 +761,13 @@ int recorder_dispatcher_prepare(muse_module_h module)
 
        if (muse_recorder->type == MUSE_RECORDER_TYPE_VIDEO) {
                client_fd = muse_server_module_get_msg_fd(module);
+               if (client_fd < 0) {
+                       ret = RECORDER_ERROR_INVALID_OPERATION;
+                       LOGE("failed to get fd %d", client_fd);
+                       muse_recorder_msg_return(api, class, ret, module);
+                       return MUSE_RECORDER_ERROR_INVALID;
+               }
+
                if (!muse_server_security_check_cynara(client_fd, CAMERA_PRIVILEGE_NAME)) {
                        LOGE("security(camera) check failed");
                        ret = RECORDER_ERROR_PERMISSION_DENIED;
@@ -816,6 +823,13 @@ int recorder_dispatcher_start(muse_module_h module)
 
        /* privilege check */
        client_fd = muse_server_module_get_msg_fd(module);
+       if (client_fd < 0) {
+               ret = RECORDER_ERROR_INVALID_OPERATION;
+               LOGE("failed to get fd %d", client_fd);
+               muse_recorder_msg_return(api, class, ret, module);
+               return MUSE_RECORDER_ERROR_INVALID;
+       }
+
        if (!muse_server_security_check_cynara(client_fd, RECORDER_PRIVILEGE_NAME)) {
                LOGE("security(recorder) check failed");
                ret = RECORDER_ERROR_PERMISSION_DENIED;
index 78f0657..88d97e1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-recorder
 Summary:    A Recorder module for muse server
-Version:    0.3.10
+Version:    0.3.11
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0