ecore-wl2: Fix issue of passing negative number to close() and read()

We should be checking the return value of ecore_main_fd_handler_fd_get
calls as they can return a negative number...which cannot be passed to
the close() or read() functions.

Fixes Coverity CID1357152 and CID1357153

@fix

Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
This commit is contained in:
Chris Michael 2016-06-30 11:07:09 -04:00
parent 35f76fe8a8
commit 79277d1cb4
1 changed files with 7 additions and 3 deletions

View File

@ -223,13 +223,15 @@ _selection_data_ready_cb_free(void *data EINA_UNUSED, void *event)
static Eina_Bool
_selection_data_read(void *data, Ecore_Fd_Handler *fdh)
{
int len;
int len, fd;
char buffer[PATH_MAX];
Ecore_Wl2_Dnd_Source *source = data;
Ecore_Wl2_Event_Selection_Data_Ready *event;
Eina_Bool ret;
len = read(ecore_main_fd_handler_fd_get(fdh), buffer, sizeof buffer);
fd = ecore_main_fd_handler_fd_get(fdh);
if (fd >= 0)
len = read(fd, buffer, sizeof buffer);
event = calloc(1, sizeof(Ecore_Wl2_Event_Selection_Data_Ready));
if (!event) return ECORE_CALLBACK_CANCEL;
@ -243,7 +245,9 @@ _selection_data_read(void *data, Ecore_Fd_Handler *fdh)
WL_DATA_OFFER_FINISH_SINCE_VERSION)
wl_data_offer_finish(source->offer);
}
close(ecore_main_fd_handler_fd_get(source->fdh));
fd = ecore_main_fd_handler_fd_get(source->fdh);
if (fd >= 0) close(fd);
ecore_main_fd_handler_del(source->fdh);
source->fdh = NULL;