Update the file descriptor valid checker 20/321020/3 accepted/tizen_9.0_unified tizen_9.0 accepted/tizen/9.0/unified/20250319.161943
authorYoungHun Kim <yh8004.kim@samsung.com>
Thu, 13 Mar 2025 06:03:24 +0000 (15:03 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Thu, 13 Mar 2025 09:23:59 +0000 (18:23 +0900)
Change-Id: Id1b19cfc353135cb6da7cbdd38df02b8af03dbc9

core/src/muse_core.c
packaging/mused.spec

index 6eaa0ebe86a6de011c76859d6757e393a917a491..68f1319a272878a489337b90d9769649a16e8ec9 100644 (file)
@@ -364,8 +364,24 @@ int muse_core_set_socket_timeout(int sock_fd, int timeout_sec)
 
 bool muse_core_fd_is_valid(int fd)
 {
+       int err = 0;
+
+       if (fcntl(fd, F_GETFL) == -1) {
+               err = errno;
+               LOGE("fcntl(F_GETFL) failed on [fd %d, errno %d]", fd, err);
+
+               if (err == EBADF)
+                       return false;
+       }
+
+       if (fd <= STDERR_FILENO) {
+               LOGE("fd %d is invalid", fd);
+               return false;
+       }
+
        muse_core_update_fd_state(fd);
-       return (fcntl(fd, F_GETFL) != MUSE_ERR || errno != EBADF) && (fd > STDERR_FILENO);
+
+       return true;
 }
 
 void muse_core_fd_close(int fd)
index 14d1947e49a97268edbc1170803c27c4d75d92c1..5bbfad30ebdaf4a057d162d50123ed480530aed1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mused
 Summary:    A multimedia daemon
-Version:    0.4.11
+Version:    0.4.12
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0