summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-06-30 11:07:09 -0400
committerChris Michael <cpmichael@osg.samsung.com>2016-06-30 11:09:11 -0400
commit79277d1cb48f750b44b8e9dc35c10433187eebd2 (patch)
tree1967d91eee85daef6fdfe0cc0eeaf5dfeb733c52 /src
parent35f76fe8a8988d3664628cf83f3ea77a7cbb5c76 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_dnd.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_dnd.c b/src/lib/ecore_wl2/ecore_wl2_dnd.c
index b885356..b696a2d 100644
--- a/src/lib/ecore_wl2/ecore_wl2_dnd.c
+++ b/src/lib/ecore_wl2/ecore_wl2_dnd.c
@@ -223,13 +223,15 @@ _selection_data_ready_cb_free(void *data EINA_UNUSED, void *event)
223static Eina_Bool 223static Eina_Bool
224_selection_data_read(void *data, Ecore_Fd_Handler *fdh) 224_selection_data_read(void *data, Ecore_Fd_Handler *fdh)
225{ 225{
226 int len; 226 int len, fd;
227 char buffer[PATH_MAX]; 227 char buffer[PATH_MAX];
228 Ecore_Wl2_Dnd_Source *source = data; 228 Ecore_Wl2_Dnd_Source *source = data;
229 Ecore_Wl2_Event_Selection_Data_Ready *event; 229 Ecore_Wl2_Event_Selection_Data_Ready *event;
230 Eina_Bool ret; 230 Eina_Bool ret;
231 231
232 len = read(ecore_main_fd_handler_fd_get(fdh), buffer, sizeof buffer); 232 fd = ecore_main_fd_handler_fd_get(fdh);
233 if (fd >= 0)
234 len = read(fd, buffer, sizeof buffer);
233 235
234 event = calloc(1, sizeof(Ecore_Wl2_Event_Selection_Data_Ready)); 236 event = calloc(1, sizeof(Ecore_Wl2_Event_Selection_Data_Ready));
235 if (!event) return ECORE_CALLBACK_CANCEL; 237 if (!event) return ECORE_CALLBACK_CANCEL;
@@ -243,7 +245,9 @@ _selection_data_read(void *data, Ecore_Fd_Handler *fdh)
243 WL_DATA_OFFER_FINISH_SINCE_VERSION) 245 WL_DATA_OFFER_FINISH_SINCE_VERSION)
244 wl_data_offer_finish(source->offer); 246 wl_data_offer_finish(source->offer);
245 } 247 }
246 close(ecore_main_fd_handler_fd_get(source->fdh)); 248
249 fd = ecore_main_fd_handler_fd_get(source->fdh);
250 if (fd >= 0) close(fd);
247 ecore_main_fd_handler_del(source->fdh); 251 ecore_main_fd_handler_del(source->fdh);
248 source->fdh = NULL; 252 source->fdh = NULL;
249 253