raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9c3df02c4183974013a7d515740911341414f708

commit 9c3df02c4183974013a7d515740911341414f708
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Fri Feb 3 14:39:57 2017 +0900

    edje - fix crash on loading ancient edje files
    
    ancient edje files dont put hash strings in the file dictionary but
    instead inline and thus the strings cannot be direct added... silly
    ancient files.
    
    this is a horrible ugly workaround this but there isn't really
    anything better than trying to detect such files (which dont seem to
    have an older version in them i can find?) so detect by pointer
    address and mapping the file.
    
    this fixes T5138
    
    @fix
---
 src/lib/edje/edje_cache.c | 22 ++++++++++++++++++++++
 src/lib/edje/edje_data.c  | 11 ++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/lib/edje/edje_cache.c b/src/lib/edje/edje_cache.c
index 0199f4d..c38e943 100644
--- a/src/lib/edje/edje_cache.c
+++ b/src/lib/edje/edje_cache.c
@@ -278,6 +278,12 @@ _edje_file_coll_open(Edje_File *edf, const char *coll)
    return edc;
 }
 
+// XXX: this is not pretty. some oooooold edje files do not store strings
+// in their dictionary for hashes. this works around crashes loading such
+// files
+extern size_t  _edje_data_string_mapping_size;
+extern void   *_edje_data_string_mapping;
+
 static Edje_File *
 _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool 
coll)
 {
@@ -289,6 +295,8 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t 
mtime, Eina_Bool coll
    Eina_List *l, *ll;
    Eet_File *ef;
    char *name;
+   void *mapping;
+   size_t mapping_size;
 
    ef = eet_mmap(f);
    if (!ef)
@@ -296,7 +304,21 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t 
mtime, Eina_Bool coll
         *error_ret = EDJE_LOAD_ERROR_UNKNOWN_FORMAT;
         return NULL;
      }
+   // XXX: ancient edje file workaround
+   mapping = eina_file_map_all((Eina_File *)f, EINA_FILE_SEQUENTIAL);
+   if (mapping)
+     {
+        mapping_size = eina_file_size_get(f);
+        _edje_data_string_mapping = mapping;
+        _edje_data_string_mapping_size = mapping_size;
+     }
    edf = eet_data_read(ef, _edje_edd_edje_file, "edje/file");
+   // XXX: ancient edje file workaround
+   if (mapping)
+     {
+        eina_file_map_free((Eina_File *)f, mapping);
+        _edje_data_string_mapping = NULL;
+     }
    if (!edf)
      {
         *error_ret = EDJE_LOAD_ERROR_CORRUPT_FILE;
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index df21571..e6d2fbb 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -639,6 +639,9 @@ _edje_description_variant_type_set(const char *type, void 
*data, Eina_Bool unkno
    return EINA_FALSE;
 }
 
+size_t  _edje_data_string_mapping_size = 0;
+void   *_edje_data_string_mapping = NULL;
+
 static Eina_Hash *
 _edje_eina_hash_add_alloc(Eina_Hash *hash,
                           const char *key,
@@ -650,7 +653,13 @@ _edje_eina_hash_add_alloc(Eina_Hash *hash,
    if (!hash)
      return NULL;
 
-   eina_hash_direct_add(hash, key, data);
+   // XXX: ancient edje file workaround
+   if ((_edje_data_string_mapping) &&
+       ((key >=  (char *)_edje_data_string_mapping) &&
+        (key <  ((char *)_edje_data_string_mapping + 
_edje_data_string_mapping_size))))
+     eina_hash_direct_add(hash, key, data);
+   else
+     eina_hash_add(hash, key, data);
    return hash;
 }
 

-- 


Reply via email to