jackdanielz pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=d451e9db710774e907f28f79480bfa239a052bfa

commit d451e9db710774e907f28f79480bfa239a052bfa
Author: Daniel Zaoui <daniel.za...@samsung.com>
Date:   Sun Jun 14 11:12:36 2015 +0300

    DnD/X11: Fix invalid access to memory
    
    It seems X doesn't send the data with the termination.
---
 src/lib/elm_cnp.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index d7619c1..702ece9 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -1047,27 +1047,21 @@ _x11_data_preparer_uri(Ecore_X_Event_Selection_Notify 
*notify,
    else
      {
         Efreet_Uri *uri;
-        int len = 0;
 
-        p = (char *)data->data;
+        p = (char *)eina_memdup((unsigned char *)data->data, data->length, 
EINA_TRUE);
+        if (!p) return EINA_FALSE;
         uri = efreet_uri_decode(p);
         if (!uri)
           {
              /* Is there any reason why we care of URI without scheme? */
-             if (p[0] == '/')
-               len = data->length;
+             if (p[0] == '/') stripstr = p;
+             else free(p);
           }
         else
           {
-             p = (char *)uri->path;
-             len = strlen(p);
-          }
-        if (len > 0)
-          {
-             stripstr = malloc(len + 1);
+             free(p);
+             stripstr = (char *)eina_memdup((unsigned char *)uri->path, 
strlen(uri->path), EINA_TRUE);
              if (!stripstr) return EINA_FALSE;
-             memcpy(stripstr, p, len);
-             stripstr[len] = 0;
           }
      }
 

-- 


Reply via email to