raster pushed a commit to branch master.

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

commit d539152156e50e81e18c3eb226db8095f83bd7d1
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Wed Aug 13 09:03:02 2014 +0900

    address non nul terminated string due to strncpy
    
    this addresses CID 1230994. as such  eina_unicode_unicode_to_utf8()
    always returns a nul terminated string. so it's guaranteed. but yes -
    if string is 7 bytes or longer it will not put a nul byte on the
    destination. as such for a single unicode char this can never happen
    as in utf8 it's 6 bytes. but since eina_unicode_unicode_to_utf8()
    safely returns a nul terminated string at all times - we can just use
    strcpy safely. no need for strncpy. also handle null return from
    eina_unicode_unicode_to_utf8()
---
 src/lib/evas/canvas/evas_object_textblock.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lib/evas/canvas/evas_object_textblock.c 
b/src/lib/evas/canvas/evas_object_textblock.c
index 930c94b..ae1466c 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -6137,8 +6137,13 @@ _escaped_char_get(const char *s, const char *s_end)
           return NULL;
 
         utf8_char = eina_unicode_unicode_to_utf8(uchar, NULL);
-        strncpy(utf8_escape, utf8_char, sizeof(utf8_escape));
-        free(utf8_char);
+        // eina_unicode_unicode_to_utf8() always creates a string that
+        // is nul terminated - guaranteed
+        if (utf8_char)
+          {
+             strcpy(utf8_escape, utf8_char);
+             free(utf8_char);
+          }
 
         return utf8_escape;
      }

-- 


Reply via email to