summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-08-27 09:56:50 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:14 +0900
commit74d399ab8188cbec655c5833f77977b49d4bcae5 (patch)
tree4800a2e509453e7f9c5a330e2b8cf3a3f33a233c /src/bin
parent7bf4394198cb6803613200f055c09d32a7256853 (diff)
evas/cserve2: Fix NULL vs. empty string
Server side: Some strings were NULL, some other were empty. Client side was looking for NULL, but the shared index contained empty key.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/evas/evas_cserve2_cache.c32
-rw-r--r--src/bin/evas/evas_cserve2_index.c10
-rw-r--r--src/bin/evas/evas_cserve2_main.c7
3 files changed, 29 insertions, 20 deletions
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index bc89150db5..f351dd718d 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -197,7 +197,6 @@ _entry_load_reused(Entry *e)
197#endif 197#endif
198} 198}
199 199
200
201static int 200static int
202_shm_object_id_cmp_cb(const void *data1, const void *data2) 201_shm_object_id_cmp_cb(const void *data1, const void *data2)
203{ 202{
@@ -545,7 +544,7 @@ _font_loaded_send(Client *client, unsigned int rid)
545static void * 544static void *
546_open_request_build(Entry *entry, int *bufsize) 545_open_request_build(Entry *entry, int *bufsize)
547{ 546{
548 const char *loader_data; 547 const char *loader_data, *key, *path;
549 char *buf; 548 char *buf;
550 int size, pathlen, keylen, loaderlen; 549 int size, pathlen, keylen, loaderlen;
551 Slave_Msg_Image_Open msg; 550 Slave_Msg_Image_Open msg;
@@ -561,8 +560,12 @@ _open_request_build(Entry *entry, int *bufsize)
561 return NULL; 560 return NULL;
562 } 561 }
563 562
564 pathlen = strlen(cserve2_shared_string_get(fd->path)) + 1; 563 path = cserve2_shared_string_get(fd->path);
565 keylen = strlen(cserve2_shared_string_get(fd->key)) + 1; 564 key = cserve2_shared_string_get(fd->key);
565 if (!path) path = "";
566 if (!key) key = "";
567 pathlen = strlen(path) + 1;
568 keylen = strlen(key) + 1;
566 569
567 memset(&msg, 0, sizeof(msg)); 570 memset(&msg, 0, sizeof(msg));
568 loader_data = cserve2_shared_string_get(fd->loader_data); 571 loader_data = cserve2_shared_string_get(fd->loader_data);
@@ -574,8 +577,8 @@ _open_request_build(Entry *entry, int *bufsize)
574 if (!buf) return NULL; 577 if (!buf) return NULL;
575 578
576 memcpy(buf, &msg, sizeof(msg)); 579 memcpy(buf, &msg, sizeof(msg));
577 memcpy(buf + sizeof(msg), cserve2_shared_string_get(fd->path), pathlen); 580 memcpy(buf + sizeof(msg), path, pathlen);
578 memcpy(buf + sizeof(msg) + pathlen, cserve2_shared_string_get(fd->key), keylen); 581 memcpy(buf + sizeof(msg) + pathlen, key, keylen);
579 if (msg.has_loader_data) 582 if (msg.has_loader_data)
580 memcpy(buf + sizeof(msg) + pathlen + keylen, loader_data, loaderlen); 583 memcpy(buf + sizeof(msg) + pathlen + keylen, loader_data, loaderlen);
581 584
@@ -661,7 +664,7 @@ static void *
661_load_request_build(Image_Entry *ientry, int *bufsize) 664_load_request_build(Image_Entry *ientry, int *bufsize)
662{ 665{
663 char *buf, *ptr; 666 char *buf, *ptr;
664 const char *shmpath, *loader_data; 667 const char *shmpath, *loader_data, *path, *key;
665 int size; 668 int size;
666 int shmlen, filelen, keylen, loaderlen; 669 int shmlen, filelen, keylen, loaderlen;
667 Slave_Msg_Image_Load msg; 670 Slave_Msg_Image_Load msg;
@@ -686,8 +689,12 @@ _load_request_build(Image_Entry *ientry, int *bufsize)
686 689
687 shmpath = cserve2_shm_name_get(ientry->shm); 690 shmpath = cserve2_shm_name_get(ientry->shm);
688 shmlen = strlen(shmpath) + 1; 691 shmlen = strlen(shmpath) + 1;
689 filelen = strlen(cserve2_shared_string_get(fd->path)) + 1; 692 path = cserve2_shared_string_get(fd->path);
690 keylen = strlen(cserve2_shared_string_get(fd->key)) + 1; 693 key = cserve2_shared_string_get(fd->key);
694 if (!path) path = "";
695 if (!key) key = "";
696 filelen = strlen(path) + 1;
697 keylen = strlen(key) + 1;
691 loader_data = cserve2_shared_string_get(fd->loader_data); 698 loader_data = cserve2_shared_string_get(fd->loader_data);
692 if (loader_data) 699 if (loader_data)
693 loaderlen = strlen(loader_data) + 1; 700 loaderlen = strlen(loader_data) + 1;
@@ -724,11 +731,12 @@ _load_request_build(Image_Entry *ientry, int *bufsize)
724 731
725 memcpy(ptr, shmpath, shmlen); 732 memcpy(ptr, shmpath, shmlen);
726 ptr += shmlen; 733 ptr += shmlen;
727 memcpy(ptr, cserve2_shared_string_get(fd->path), filelen); 734 memcpy(ptr, path, filelen);
728 ptr += filelen; 735 ptr += filelen;
729 memcpy(ptr, cserve2_shared_string_get(fd->key), keylen); 736 memcpy(ptr, key, keylen);
730 ptr += keylen; 737 ptr += keylen;
731 if (loaderlen > 0) memcpy(ptr, cserve2_shared_string_get(fd->loader_data), loaderlen); 738 if (loaderlen > 0)
739 memcpy(ptr, loader_data, loaderlen);
732 740
733 *bufsize = size; 741 *bufsize = size;
734 742
diff --git a/src/bin/evas/evas_cserve2_index.c b/src/bin/evas/evas_cserve2_index.c
index 816a686d23..fdff6b5177 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -921,7 +921,7 @@ cserve2_shared_string_add(const char *str)
921 char *data; 921 char *data;
922 int len, id; 922 int len, id;
923 923
924 if (!str) return -1; 924 if (!str) return 0;
925 925
926 // Find in known strings 926 // Find in known strings
927 id = (int) (intptr_t) eina_hash_find(_string_entries, str); 927 id = (int) (intptr_t) eina_hash_find(_string_entries, str);
@@ -945,7 +945,7 @@ new_entry:
945 if (!ie) 945 if (!ie)
946 { 946 {
947 ERR("Could not store new string in shm"); 947 ERR("Could not store new string in shm");
948 return -1; 948 return 0;
949 } 949 }
950 950
951 data = _string_mempool->ds->data + ie->offset; 951 data = _string_mempool->ds->data + ie->offset;
@@ -957,7 +957,7 @@ new_entry:
957int 957int
958cserve2_shared_string_ref(int id) 958cserve2_shared_string_ref(int id)
959{ 959{
960 if (!id) return 0; 960 if (id <= 0) return 0;
961 return cserve2_shared_mempool_buffer_ref(_string_mempool, id); 961 return cserve2_shared_mempool_buffer_ref(_string_mempool, id);
962} 962}
963 963
@@ -966,7 +966,7 @@ cserve2_shared_string_del(int id)
966{ 966{
967 const char *data; 967 const char *data;
968 968
969 if (!id) return; 969 if (id <= 0) return;
970 if ((data = _shared_mempool_buffer_del(_string_mempool, id)) != NULL) 970 if ((data = _shared_mempool_buffer_del(_string_mempool, id)) != NULL)
971 { 971 {
972 if (!eina_hash_del_by_key(_string_entries, data)) 972 if (!eina_hash_del_by_key(_string_entries, data))
@@ -980,7 +980,7 @@ cserve2_shared_string_del(int id)
980const char * 980const char *
981cserve2_shared_string_get(int id) 981cserve2_shared_string_get(int id)
982{ 982{
983 if (!id) return NULL; 983 if (id <= 0) return NULL;
984 return cserve2_shared_mempool_buffer_get(_string_mempool, id); 984 return cserve2_shared_mempool_buffer_get(_string_mempool, id);
985} 985}
986 986
diff --git a/src/bin/evas/evas_cserve2_main.c b/src/bin/evas/evas_cserve2_main.c
index fa70fece3b..90a811af62 100644
--- a/src/bin/evas/evas_cserve2_main.c
+++ b/src/bin/evas/evas_cserve2_main.c
@@ -135,15 +135,17 @@ static void
135_cserve2_client_open(Client *client) 135_cserve2_client_open(Client *client)
136{ 136{
137 Msg_Open *msg = (Msg_Open *)client->msg.buf; 137 Msg_Open *msg = (Msg_Open *)client->msg.buf;
138 const char *path, *key; 138 const char *path, *key, *end;
139 139
140 path = ((const char *)msg) + sizeof(*msg) + msg->path_offset; 140 path = ((const char *)msg) + sizeof(*msg) + msg->path_offset;
141 key = ((const char *)msg) + sizeof(*msg) + msg->key_offset; 141 key = ((const char *)msg) + sizeof(*msg) + msg->key_offset;
142 end = key + strlen(key) + 1;
142 143
143 INF("Received OPEN command: RID=%d", msg->base.rid); 144 INF("Received OPEN command: RID=%d", msg->base.rid);
144 INF("File_ID: %d, path=\"%s\", key=\"%s\", has_load_opts=%d", 145 INF("File_ID: %d, path=\"%s\", key=\"%s\", has_load_opts=%d",
145 msg->file_id, path, key, (int) msg->has_load_opts); 146 msg->file_id, path, key, (int) msg->has_load_opts);
146 147
148 if (!key[0]) key = NULL;
147 cserve2_cache_file_open(client, msg->file_id, path, key, msg->base.rid); 149 cserve2_cache_file_open(client, msg->file_id, path, key, msg->base.rid);
148 150
149 if (!msg->has_load_opts) 151 if (!msg->has_load_opts)
@@ -152,8 +154,7 @@ _cserve2_client_open(Client *client)
152 else 154 else
153 { 155 {
154 // FIXME: Check message size first? 156 // FIXME: Check message size first?
155 Evas_Image_Load_Opts *opts = 157 Evas_Image_Load_Opts *opts = (Evas_Image_Load_Opts *) end;
156 (Evas_Image_Load_Opts*) (key + strlen(key) + 1);
157 158
158 DBG("Load Options:"); 159 DBG("Load Options:");
159 DBG("\tdpi: %03.1f", opts->dpi); 160 DBG("\tdpi: %03.1f", opts->dpi);