simotek pushed a commit to branch enlightenment-0.22.

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

commit eba3bec170a74cff976ec6b83826cd40aa006cbe
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Sat Mar 10 15:21:18 2018 +0900

    e systray/indicator protocol pixmap data fetch fix
    
    this fixes several issues in the pixmap data fetching
    
    1. it over-read the input buffer assuming ints count instead it has
    byte count for length
    2. it would leak memory if you have multiple pixmaps and the largest
    was not the first found.
    3. it always swapped pixel bytes instead of only on little endian.
    
    this should fix T5910
---
 src/modules/systray/e_mod_notifier_host_dbus.c | 34 ++++++++++++++++++++------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/modules/systray/e_mod_notifier_host_dbus.c 
b/src/modules/systray/e_mod_notifier_host_dbus.c
index a103c48a9..d00bc26c5 100644
--- a/src/modules/systray/e_mod_notifier_host_dbus.c
+++ b/src/modules/systray/e_mod_notifier_host_dbus.c
@@ -75,17 +75,35 @@ icon_pixmap_deserialize(Eldbus_Message_Iter *variant, 
uint32_t **data, int *w, i
              int len;
 
              //only take this img if it has a higher resolution
-             if (tmpw > *w || tmph > *h)
+             if ((tmpw > *w) || (tmph > *h))
                {
-                  *w = tmpw;
-                  *h = tmph;
                   if (eldbus_message_iter_fixed_array_get(imgdata, 'y', &img, 
&len))
                     {
-                       unsigned int pos;
-
-                       *data = malloc(len * sizeof(int));
-                       for (pos = 0; pos < (unsigned int)len; pos++)
-                         (*data)[pos] = eina_swap32(img[pos]);
+                       unsigned int sz;
+
+                       sz = tmpw * tmph;
+                       if ((unsigned int)len == (sz * 4))
+                         {
+                            uint32_t *tmp;
+
+                            tmp = malloc(tmpw * tmph * 4);
+                            if (tmp)
+                              {
+                                 uint32_t *s, *d, *e;
+
+                                 if (*data) free(*data);
+                                 *data = tmp;
+                                 *w = tmpw;
+                                 *h = tmph;
+                                 for (s = img, e = img + sz, d = *data;
+                                      s < e; s++, d++)
+#if (defined __BYTE_ORDER && __BYTE_ORDER == __LITTLE_ENDIAN) || 
(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+                                 *d = eina_swap32(*s);
+#else
+                                 *d = *s;
+#endif
+                              }
+                         }
                     }
                }
           }

-- 


Reply via email to