summaryrefslogtreecommitdiff
path: root/src/lib/ecore_x
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-09-26 11:22:32 -0400
committerChristopher Michael <cp.michael@samsung.com>2019-09-26 11:22:32 -0400
commit9d16a44334f845d8053602c30d28bd4cb600046d (patch)
tree4b941bf160373d38adc77576c5b9b26f395c30e4 /src/lib/ecore_x
parentf37c996ad42f2cd1fda5f21b056d7ef84ef84bdf (diff)
ecore-x: fix null derefs in window prop code
Summary: handle cases where null params could be passed and cause crashes @fix Reviewers: devilhorns Reviewed By: devilhorns Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9899
Diffstat (limited to 'src/lib/ecore_x')
-rw-r--r--src/lib/ecore_x/ecore_x_window_prop.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lib/ecore_x/ecore_x_window_prop.c b/src/lib/ecore_x/ecore_x_window_prop.c
index 043e50e..ac23a50 100644
--- a/src/lib/ecore_x/ecore_x_window_prop.c
+++ b/src/lib/ecore_x/ecore_x_window_prop.c
@@ -81,8 +81,9 @@ ecore_x_window_prop_card32_get(Ecore_X_Window win,
81 if (num_ret < len) 81 if (num_ret < len)
82 len = num_ret; 82 len = num_ret;
83 83
84 for (i = 0; i < len; i++) 84 if (val)
85 val[i] = ((unsigned long *)prop_ret)[i]; 85 for (i = 0; i < len; i++)
86 val[i] = ((unsigned long *)prop_ret)[i];
86 num = len; 87 num = len;
87 } 88 }
88 89
@@ -112,7 +113,7 @@ ecore_x_window_prop_card32_list_get(Ecore_X_Window win,
112 int num; 113 int num;
113 114
114 LOGFN(__FILE__, __LINE__, __FUNCTION__); 115 LOGFN(__FILE__, __LINE__, __FUNCTION__);
115 *plst = NULL; 116 if (plst) *plst = NULL;
116 prop_ret = NULL; 117 prop_ret = NULL;
117 if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False, 118 if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
118 XA_CARDINAL, &type_ret, &format_ret, &num_ret, 119 XA_CARDINAL, &type_ret, &format_ret, &num_ret,
@@ -123,7 +124,7 @@ ecore_x_window_prop_card32_list_get(Ecore_X_Window win,
123 num = -1; 124 num = -1;
124 else if ((num_ret == 0) || (!prop_ret)) 125 else if ((num_ret == 0) || (!prop_ret))
125 num = 0; 126 num = 0;
126 else 127 else if (plst)
127 { 128 {
128 val = malloc(num_ret * sizeof(unsigned int)); 129 val = malloc(num_ret * sizeof(unsigned int));
129 if (!val) 130 if (!val)
@@ -136,6 +137,8 @@ ecore_x_window_prop_card32_list_get(Ecore_X_Window win,
136 num = num_ret; 137 num = num_ret;
137 *plst = val; 138 *plst = val;
138 } 139 }
140 else
141 num = num_ret;
139 142
140 if (_ecore_xlib_sync) ecore_x_sync(); 143 if (_ecore_xlib_sync) ecore_x_sync();
141 if (prop_ret) 144 if (prop_ret)
@@ -214,8 +217,9 @@ ecore_x_window_prop_xid_get(Ecore_X_Window win,
214 if (num_ret < len) 217 if (num_ret < len)
215 len = num_ret; 218 len = num_ret;
216 219
217 for (i = 0; i < len; i++) 220 if (lst)
218 lst[i] = ((unsigned long *)prop_ret)[i]; 221 for (i = 0; i < len; i++)
222 lst[i] = ((unsigned long *)prop_ret)[i];
219 num = len; 223 num = len;
220 } 224 }
221 225
@@ -249,7 +253,7 @@ ecore_x_window_prop_xid_list_get(Ecore_X_Window win,
249 Eina_Bool success; 253 Eina_Bool success;
250 254
251 LOGFN(__FILE__, __LINE__, __FUNCTION__); 255 LOGFN(__FILE__, __LINE__, __FUNCTION__);
252 *val = NULL; 256 if (val) *val = NULL;
253 prop_ret = NULL; 257 prop_ret = NULL;
254 success = (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False, 258 success = (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
255 type, &type_ret, &format_ret, &num_ret, 259 type, &type_ret, &format_ret, &num_ret,
@@ -261,7 +265,7 @@ ecore_x_window_prop_xid_list_get(Ecore_X_Window win,
261 num = -1; 265 num = -1;
262 else if (num_ret == 0 || !prop_ret) 266 else if (num_ret == 0 || !prop_ret)
263 num = 0; 267 num = 0;
264 else 268 else if (val)
265 { 269 {
266 alst = malloc(num_ret * sizeof(Ecore_X_ID)); 270 alst = malloc(num_ret * sizeof(Ecore_X_ID));
267 for (i = 0; i < num_ret; i++) 271 for (i = 0; i < num_ret; i++)
@@ -269,6 +273,8 @@ ecore_x_window_prop_xid_list_get(Ecore_X_Window win,
269 num = num_ret; 273 num = num_ret;
270 *val = alst; 274 *val = alst;
271 } 275 }
276 else
277 num = num_ret;
272 278
273 if (prop_ret) 279 if (prop_ret)
274 XFree(prop_ret); 280 XFree(prop_ret);