summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-07-16 16:31:53 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-07-16 16:31:53 +0900
commit5e58e58d60e4f991f2f9df6d98c4722e21b482ea (patch)
tree24374844ecd11b291418f8cb575402b0a0f56beb
parent6fa8c581b564cf85eba89cbb61ebaa067f7da051 (diff)
efl selection manager + elm dnd test fix with bad string handling
so there are 2 problems behind T7113. first is a problem in the efl selection manager being "sloppy" with selection data. it's doing a strlen on the data but it's not a normal c string. it's a blob of binary data + length value. this fixes that "sloppiness" by using the len field. there is also another bug in the dnd test code that again has to do with "sloppy" handling of data buffers and assuming nul byte termination and not using the len field properly. this fixes T7113.
-rw-r--r--src/bin/elementary/test_dnd.c10
-rw-r--r--src/examples/elementary/codegen_example.edjbin12063 -> 0 bytes
-rw-r--r--src/lib/elementary/efl_selection_manager.c9
3 files changed, 14 insertions, 5 deletions
diff --git a/src/bin/elementary/test_dnd.c b/src/bin/elementary/test_dnd.c
index 2e5aab507f..93bed2a397 100644
--- a/src/bin/elementary/test_dnd.c
+++ b/src/bin/elementary/test_dnd.c
@@ -204,11 +204,15 @@ _grid_item_getcb(Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *xposret, int
204static inline char * 204static inline char *
205_strndup(const char *str, size_t len) 205_strndup(const char *str, size_t len)
206{ 206{
207 size_t slen = strlen(str); 207 const char *p;
208 char *ret; 208 char *ret;
209 size_t slen;
209 210
210 if (slen > len) slen = len; 211 for (slen = 0, p = str;
211 ret = malloc (slen + 1); 212 (slen < len) && (*p);
213 p++, slen++);
214
215 ret = malloc(slen + 1);
212 if (!ret) return NULL; 216 if (!ret) return NULL;
213 217
214 if (slen > 0) memcpy(ret, str, slen); 218 if (slen > 0) memcpy(ret, str, slen);
diff --git a/src/examples/elementary/codegen_example.edj b/src/examples/elementary/codegen_example.edj
deleted file mode 100644
index 4f87ec8c82..0000000000
--- a/src/examples/elementary/codegen_example.edj
+++ /dev/null
Binary files differ
diff --git a/src/lib/elementary/efl_selection_manager.c b/src/lib/elementary/efl_selection_manager.c
index 24132d44fb..0498820e98 100644
--- a/src/lib/elementary/efl_selection_manager.c
+++ b/src/lib/elementary/efl_selection_manager.c
@@ -1133,11 +1133,16 @@ static Eina_Bool
1133_x11_vcard_send(char *target EINA_UNUSED, void *data EINA_UNUSED, int size EINA_UNUSED, void **data_ret, int *size_ret, Ecore_X_Atom *ttype EINA_UNUSED, int *typesize EINA_UNUSED) 1133_x11_vcard_send(char *target EINA_UNUSED, void *data EINA_UNUSED, int size EINA_UNUSED, void **data_ret, int *size_ret, Ecore_X_Atom *ttype EINA_UNUSED, int *typesize EINA_UNUSED)
1134{ 1134{
1135 Sel_Manager_Selection *sel; 1135 Sel_Manager_Selection *sel;
1136 char *s;
1136 1137
1137 sel_debug("Vcard send called"); 1138 sel_debug("Vcard send called");
1138 sel = *(Sel_Manager_Selection **)data; 1139 sel = *(Sel_Manager_Selection **)data;
1139 if (data_ret) *data_ret = strdup(sel->data.mem); 1140 s = malloc(sel->data.len + 1);
1140 if (size_ret) *size_ret = strlen(sel->data.mem); 1141 if (!s) return EINA_FALSE;
1142 memcpy(s, sel->data.mem, sel->data.len);
1143 s[sel->data.len] = 0;
1144 if (data_ret) *data_ret = s;
1145 if (size_ret) *size_ret = sel->data.len;
1141 return EINA_TRUE; 1146 return EINA_TRUE;
1142} 1147}
1143 1148