From: Seungbae Shin Date: Tue, 10 Oct 2017 07:07:36 +0000 (+0900) Subject: Fix Coverity defects X-Git-Tag: submit/tizen_4.0/20171013.073227^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33d3047ccfd521bc552f24a2e3959af6c01f7a68;p=platform%2Fcore%2Fmultimedia%2Flibmm-session.git Fix Coverity defects [Version] 0.2.15 [Issue Type] Security Change-Id: I8339fc77cf2978f9a800a61423da0865d8e2f64a (cherry picked from commit c276d981d636c4c5ff3633375dc396e215069a14) --- diff --git a/mm_session.c b/mm_session.c index b7e8a49..1358df0 100644 --- a/mm_session.c +++ b/mm_session.c @@ -266,6 +266,7 @@ int _mm_session_util_read_type(int app_pid, int *sessiontype) pid_t mypid; int fd = -1; char filename[MAX_FILE_LENGTH]; + int result = MM_ERROR_NONE; debug_fenter(); @@ -283,15 +284,20 @@ int _mm_session_util_read_type(int app_pid, int *sessiontype) if (fd < 0) return MM_ERROR_INVALID_HANDLE; - read(fd, sessiontype, sizeof(int)); - *sessiontype = *sessiontype >> 16; - debug_warning("read sessiontype(%d) from /tmp/mm_session_%d", *sessiontype, mypid); + if (read(fd, sessiontype, sizeof(int)) == sizeof(int)) { + *sessiontype = *sessiontype >> 16; + debug_warning("read sessiontype(%d) from /tmp/mm_session_%d", *sessiontype, mypid); + } else { + debug_error("failed to read from %s, errno %d", filename, errno); + result = MM_ERROR_INVALID_HANDLE; + } + close(fd); ////// READ SESSION TYPE ///////// debug_fleave(); - return MM_ERROR_NONE; + return result; } EXPORT_API @@ -341,6 +347,7 @@ int _mm_session_util_read_information(int app_pid, int *session_type, int *flags int fd = -1; char filename[MAX_FILE_LENGTH]; int result_info = 0; + int result = MM_ERROR_NONE; debug_fenter(); @@ -357,17 +364,21 @@ int _mm_session_util_read_information(int app_pid, int *session_type, int *flags fd = open(filename, O_RDONLY); if (fd < 0) return MM_ERROR_INVALID_HANDLE; - read(fd, &result_info, sizeof(int)); - *session_type = result_info >> 16; - *flags = result_info & 0x0000ffff; + if (read(fd, &result_info, sizeof(int)) == sizeof(int)) { + *session_type = result_info >> 16; + *flags = result_info & 0x0000ffff; + debug_warning("read session_type(%d), session_option(%x) from /tmp/mm_session_%d", *session_type, *flags, mypid); + } else { + debug_error("failed to read from %s, errno %d", filename, errno); + result = MM_ERROR_INVALID_HANDLE; + } - debug_warning("read session_type(%d), session_option(%x) from /tmp/mm_session_%d", *session_type, *flags, mypid); close(fd); ////// READ SESSION INFO ///////// debug_fleave(); - return MM_ERROR_NONE; + return result; } void __session_signal_handler(int signo, siginfo_t *siginfo, void *context) diff --git a/packaging/libmm-session.spec b/packaging/libmm-session.spec index aa9113a..d862329 100644 --- a/packaging/libmm-session.spec +++ b/packaging/libmm-session.spec @@ -1,6 +1,6 @@ Name: libmm-session Summary: Multimedia Session Library -Version: 0.2.14 +Version: 0.2.15 Release: 0 Group: Multimedia/Libraries License: Apache-2.0