efreet: reject invalid "" data for Efreet_Desktop->x hash
authorMike Blumenkrantz <zmike@osg.samsung.com>
Mon, 25 Jan 2016 16:20:55 +0000 (11:20 -0500)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Mon, 25 Jan 2016 16:27:01 +0000 (11:27 -0500)
ref T3096

@fix

src/lib/efreet/efreet_desktop.c

index a49a975..f3cef0c 100644 (file)
@@ -515,6 +515,7 @@ efreet_desktop_x_field_set(Efreet_Desktop *desktop, const char *key, const char
 {
     EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, EINA_FALSE);
     EINA_SAFETY_ON_TRUE_RETURN_VAL(strncmp(key, "X-", 2), EINA_FALSE);
+    EINA_SAFETY_ON_TRUE_RETURN_VAL(data && (!data[0]), EINA_FALSE);
 
     eina_lock_take(&_lock);
     if (!desktop->x)
@@ -537,10 +538,15 @@ efreet_desktop_x_field_get(Efreet_Desktop *desktop, const char *key)
     EINA_SAFETY_ON_TRUE_RETURN_VAL(strncmp(key, "X-", 2), NULL);
 
     ret = eina_hash_find(desktop->x, key);
-    if (!ret)
-        return NULL;
+    ret = eina_stringshare_add(ret);
+    if (ret && (!ret[0]))
+      {
+         /* invalid null key somehow accepted; remove */
+         efreet_desktop_x_field_del(desktop, key);
+         eina_stringshare_replace(&ret, NULL);
+      }
 
-    return eina_stringshare_add(ret);
+    return ret;
 }
 
 EAPI Eina_Bool