wayland-client: check fd is a valid value
authorjeon <jhyuni.kang@samsung.com>
Fri, 31 Jan 2020 07:55:39 +0000 (16:55 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 16 Feb 2023 10:10:31 +0000 (19:10 +0900)
  - fix a svace issue: tainted integer

Change-Id: I1aaf98f93f06383599643d1febd8315901a7f438

src/wayland-client.c

index d281a65..dfb322f 100644 (file)
@@ -44,6 +44,7 @@
 #include <poll.h>
 #include <pthread.h>
 #include <sys/time.h>
+#include <limits.h>
 
 #include "wayland-util.h"
 #include "wayland-os.h"
@@ -1518,6 +1519,9 @@ wl_display_connect(const char *name)
                        return NULL;
                errno = prev_errno;
 
+               if (fd < 0 || fd > INT_MAX - 1)
+                       return NULL;
+
                flags = fcntl(fd, F_GETFD);
                if (flags == -1 && errno == EBADF)
                        return NULL;