diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2018-07-16 16:31:53 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2018-07-16 16:31:53 +0900 |
commit | 5e58e58d60e4f991f2f9df6d98c4722e21b482ea (patch) | |
tree | 24374844ecd11b291418f8cb575402b0a0f56beb | |
parent | 6fa8c581b564cf85eba89cbb61ebaa067f7da051 (diff) | |
download | efl-5e58e58d60e4f991f2f9df6d98c4722e21b482ea.tar.gz |
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.c | 10 | ||||
-rw-r--r-- | src/examples/elementary/codegen_example.edj | bin | 12063 -> 0 bytes | |||
-rw-r--r-- | src/lib/elementary/efl_selection_manager.c | 9 |
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 static inline char * _strndup(const char *str, size_t len) { - size_t slen = strlen(str); + const char *p; char *ret; + size_t slen; - if (slen > len) slen = len; - ret = malloc (slen + 1); + for (slen = 0, p = str; + (slen < len) && (*p); + p++, slen++); + + ret = malloc(slen + 1); if (!ret) return NULL; if (slen > 0) memcpy(ret, str, slen); diff --git a/src/examples/elementary/codegen_example.edj b/src/examples/elementary/codegen_example.edj Binary files differdeleted file mode 100644 index 4f87ec8c82..0000000000 --- a/src/examples/elementary/codegen_example.edj +++ /dev/null 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 _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) { Sel_Manager_Selection *sel; + char *s; sel_debug("Vcard send called"); sel = *(Sel_Manager_Selection **)data; - if (data_ret) *data_ret = strdup(sel->data.mem); - if (size_ret) *size_ret = strlen(sel->data.mem); + s = malloc(sel->data.len + 1); + if (!s) return EINA_FALSE; + memcpy(s, sel->data.mem, sel->data.len); + s[sel->data.len] = 0; + if (data_ret) *data_ret = s; + if (size_ret) *size_ret = sel->data.len; return EINA_TRUE; } |