acm: Fix coverity defects 75/211675/2 accepted/tizen/unified/20190809.110817 submit/tizen/20190809.041132
authorSeungbae Shin <seungbae.shin@samsung.com>
Thu, 8 Aug 2019 04:49:27 +0000 (13:49 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Thu, 8 Aug 2019 10:15:19 +0000 (19:15 +0900)
[Version] 11.1.68
[Issue Type] Security

Change-Id: I4a8f4a0d6136c3c52716e1c4e682a9d574991f5a

packaging/pulseaudio-modules-tizen.spec
src/acm.c

index fbfdda3..266fb6a 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          11.1.67
+Version:          11.1.68
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index e520ee9..2019e52 100644 (file)
--- a/src/acm.c
+++ b/src/acm.c
@@ -240,10 +240,21 @@ static int ipc_get_client_fd(struct userdata *u, ipc_channel_t channel)
 
     if (channel == IPC_CHANNEL_DATA) {
         n_opt_val = 19200;
-        setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *) &n_opt_val, n_opt_len);
+        ret = setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *) &n_opt_val, n_opt_len);
+        if (ret == -1) {
+            pa_log_error("unable to setsockopt SO_SNDBUF socket fd %d: %s", sockfd, pa_cstrerror(errno));
+            close(sockfd);
+            return -1;
+        }
+
         socket_path = u->data_socket_path;
     }
-    getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *) &n_opt_val, &n_opt_len);
+    ret = getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *) &n_opt_val, &n_opt_len);
+    if (ret == -1) {
+        pa_log_error("unable to getsockopt SO_SNDBUF socket fd %d: %s", sockfd, pa_cstrerror(errno));
+        close(sockfd);
+        return -1;
+    }
     pa_log_info("sockfd: %d,  socket send buffer size: %d", sockfd, n_opt_val);
 
     if (fcntl(sockfd, F_SETFD, FD_CLOEXEC) < 0) {
@@ -254,12 +265,17 @@ static int ipc_get_client_fd(struct userdata *u, ipc_channel_t channel)
 
     if (channel == IPC_CHANNEL_MSG) {
         int flag = fcntl(sockfd, F_GETFL, 0);
+        if (flag == -1) {
+            pa_log_error("unable to get file status on socket fd %d: %s", sockfd, pa_cstrerror(errno));
+            close(sockfd);
+            return -1;
+        }
         fcntl(sockfd, F_SETFL, flag | O_NONBLOCK);
     }
 
     memset(&address, 0, sizeof(address));
     address.sun_family = AF_UNIX;
-    strncpy(address.sun_path, socket_path, sizeof(address.sun_path));
+    strncpy(address.sun_path, socket_path, sizeof(address.sun_path) - 1);
     len = sizeof(address);
 
     if ((ret = connect(sockfd, (struct sockaddr *)&address, len)) < 0) {