summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
diff options
context:
space:
mode:
authorChristopher Michael <devilhorns@comcast.net>2020-03-10 10:31:46 -0400
committerChristopher Michael <devilhorns@comcast.net>2020-03-10 10:31:46 -0400
commit8009817d0773eb5ad2b6bbccc7f6f19c50f218ca (patch)
tree89b662c9ac16f85a58c69cdf3501e1439d307120 /src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
parentbe87c4a0c22a88014d2061e255a7a1b65706efa1 (diff)
ecore-evas-wayland: Check for valid 'fd' before passing to write()
write() cannot be passed a negative value. If ecore_main_fd_handler_fd_get returns -1, then this is an issue. Check for valid fd being returned from fd_handler_fd_get and if it is negative, then cleanup and get out. Fixes CID1420318
Diffstat (limited to '')
-rw-r--r--src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
index 0c80b501cb..36d64d9940 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
@@ -2603,9 +2603,12 @@ typedef struct {
2603static Eina_Bool 2603static Eina_Bool
2604_write_to_fd(void *data, Ecore_Fd_Handler *fd_handler) 2604_write_to_fd(void *data, Ecore_Fd_Handler *fd_handler)
2605{ 2605{
2606 int fd = ecore_main_fd_handler_fd_get(fd_handler); 2606 int fd;
2607 Delayed_Writing *slice = data; 2607 Delayed_Writing *slice = data;
2608 2608
2609 fd = ecore_main_fd_handler_fd_get(fd_handler);
2610 if (fd < 0) goto end;
2611
2609 size_t len = write(fd, slice->slice.mem + slice->written_bytes, slice->slice.len - slice->written_bytes); 2612 size_t len = write(fd, slice->slice.mem + slice->written_bytes, slice->slice.len - slice->written_bytes);
2610 2613
2611 slice->written_bytes += len; 2614 slice->written_bytes += len;
@@ -2615,13 +2618,13 @@ _write_to_fd(void *data, Ecore_Fd_Handler *fd_handler)
2615 } 2618 }
2616 else 2619 else
2617 { 2620 {
2621end:
2618 ecore_main_fd_handler_del(fd_handler); 2622 ecore_main_fd_handler_del(fd_handler);
2619 free(slice->slice.mem); 2623 free(slice->slice.mem);
2620 free(slice); 2624 free(slice);
2621 close(fd); 2625 close(fd);
2622 return EINA_FALSE; 2626 return EINA_FALSE;
2623 } 2627 }
2624
2625} 2628}
2626 2629
2627static Eina_Bool 2630static Eina_Bool