summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-09-25 18:57:04 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 11:09:52 +0900
commite2fef934748c36ba59962497d075730020c9304b (patch)
tree372a7a0c2ccde89853e364b50c440f430d61c38b
parent81ec95eb4250d3a303fc0f09f45e7710c18464f0 (diff)
downloadefl-e2fef934748c36ba59962497d075730020c9304b.tar.gz
evas/cserve2: Fix invalid file referencing in client
Fixes elementary_test "Bg Image": - Various load_opts (jpeg geometry) where not handled properly by the client.
-rw-r--r--src/bin/evas/evas_cserve2_slave.c12
-rw-r--r--src/lib/evas/cserve2/evas_cs2_client.c97
2 files changed, 58 insertions, 51 deletions
diff --git a/src/bin/evas/evas_cserve2_slave.c b/src/bin/evas/evas_cserve2_slave.c
index 43fc3a5b19..7aeac6b370 100644
--- a/src/bin/evas/evas_cserve2_slave.c
+++ b/src/bin/evas/evas_cserve2_slave.c
@@ -434,8 +434,8 @@ image_load(const char *file, const char *key, const char *shmfile,
}
memset(&property, 0, sizeof (property));
- property.w = params->w;
- property.h = params->h;
+ property.w = params->opts.w; // Should we rather use params->w ?
+ property.h = params->opts.h;
skey = eina_stringshare_add(key);
loader_data = _image_file_open(fd, skey, opts, module, &property, &animated, &funcs);
@@ -446,6 +446,14 @@ image_load(const char *file, const char *key, const char *shmfile,
goto done;
}
+ if (params->shm.mmap_size < (int) (property.w * property.h * 4))
+ {
+ printf("LOAD failed at %s:%d: shm map is too small (%d) for this image (%ux%u)\n",
+ __FUNCTION__, __LINE__,
+ params->shm.mmap_size, property.w , property.h);
+ goto done;
+ }
+
ok = funcs->file_data(loader_data, &property, map, &error);
if (!ok || (error != EVAS_LOAD_ERROR_NONE))
{
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c
index e6f43a73cb..fa29fab223 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -705,15 +705,56 @@ _build_absolute_path(const char *path, char buf[], int size)
return len;
}
+// NOTE: Copy & paste from evas_cserve2_cache.c (TODO: Merge into common file)
+static Eina_Bool
+_evas_image_load_opts_empty(Evas_Image_Load_Opts *lo)
+{
+ if (!lo) return EINA_TRUE;
+
+ return ((lo->scale_down_by == 0)
+ && (lo->dpi == 0.0)
+ && (lo->w == 0) && (lo->h == 0)
+ && (lo->region.x == 0) && (lo->region.y == 0)
+ && (lo->region.w == 0) && (lo->region.h == 0)
+ && (lo->orientation == 0));
+}
+
+static void
+_file_hkey_get(char *buf, size_t sz, const char *path, const char *key,
+ Evas_Image_Load_Opts *lo)
+{
+ // Same as _evas_cache_image_loadopts_append() but not optimized :)
+ if (lo && _evas_image_load_opts_empty(lo))
+ lo = NULL;
+
+ if (!lo)
+ snprintf(buf, sz, "%s:%s", path, key);
+ else
+ {
+ if (lo->orientation)
+ {
+ snprintf(buf, sz, "%s:%s//@/%d/%f/%dx%d/%d+%d.%dx%d",
+ path, key, lo->scale_down_by, lo->dpi, lo->w, lo->h,
+ lo->region.x, lo->region.y, lo->region.w, lo->region.h);
+ }
+ else
+ {
+ snprintf(buf, sz, "%s:%s//@/%d/%f/%dx%d/%d+%d.%dx%d/o",
+ path, key, lo->scale_down_by, lo->dpi, lo->w, lo->h,
+ lo->region.x, lo->region.y, lo->region.w, lo->region.h);
+ }
+ }
+}
+
static unsigned int
_image_open_server_send(Image_Entry *ie, const char *file, const char *key,
Evas_Image_Load_Opts *opts)
{
int flen, klen;
- int size;
+ int size, hkey_len;
char *buf;
char filebuf[PATH_MAX];
- char *file_hkey;
+ char *hkey;
Msg_Open msg_open;
File_Entry *fentry;
Data_Entry *dentry;
@@ -738,11 +779,10 @@ _image_open_server_send(Image_Entry *ie, const char *file, const char *key,
if (!key) key = "";
klen = strlen(key) + 1;
- file_hkey = alloca(flen + klen);
- memcpy(file_hkey, file, flen);
- file_hkey[flen - 1] = ':';
- memcpy(file_hkey + flen, key, klen);
- fentry = eina_hash_find(_file_entries, file_hkey);
+ hkey_len = flen + klen + 1024;
+ hkey = alloca(hkey_len);
+ _file_hkey_get(hkey, hkey_len, filebuf, key, opts);
+ fentry = eina_hash_find(_file_entries, hkey);
if (!fentry)
{
fentry = calloc(1, sizeof(*fentry));
@@ -750,7 +790,7 @@ _image_open_server_send(Image_Entry *ie, const char *file, const char *key,
return 0;
fentry->file_id = ++_file_id;
- fentry->hkey = eina_stringshare_add(file_hkey);
+ fentry->hkey = eina_stringshare_add(hkey);
eina_hash_direct_add(_file_entries, fentry->hkey, fentry);
}
fentry->refcount++;
@@ -2069,47 +2109,6 @@ _shared_string_get(int id)
do { if (!_shared_index_remap_check(&(si), sizeof(typ))) { \
CRIT("Failed to remap index"); return NULL; } } while (0)
-
-static Eina_Bool
-_evas_image_load_opts_empty(Evas_Image_Load_Opts *lo)
-{
- if (!lo) return EINA_TRUE;
-
- return ((lo->scale_down_by == 0)
- && (lo->dpi == 0.0)
- && (lo->w == 0) && (lo->h == 0)
- && (lo->region.x == 0) && (lo->region.y == 0)
- && (lo->region.w == 0) && (lo->region.h == 0)
- && (lo->orientation == 0));
-}
-
-static void
-_file_hkey_get(char *buf, size_t sz, const char *path, const char *key,
- Evas_Image_Load_Opts *lo)
-{
- // Same as _evas_cache_image_loadopts_append() but not optimized :)
- if (lo && _evas_image_load_opts_empty(lo))
- lo = NULL;
-
- if (!lo)
- snprintf(buf, sz, "%s:%s", path, key);
- else
- {
- if (lo->orientation)
- {
- snprintf(buf, sz, "%s:%s//@/%d/%f/%dx%d/%d+%d.%dx%d",
- path, key, lo->scale_down_by, lo->dpi, lo->w, lo->h,
- lo->region.x, lo->region.y, lo->region.w, lo->region.h);
- }
- else
- {
- snprintf(buf, sz, "%s:%s//@/%d/%f/%dx%d/%d+%d.%dx%d/o",
- path, key, lo->scale_down_by, lo->dpi, lo->w, lo->h,
- lo->region.x, lo->region.y, lo->region.w, lo->region.h);
- }
- }
-}
-
static const File_Data *
_shared_image_entry_file_data_find(Image_Entry *ie)
{