Fix buffer overflow issue in autoperiod 05/81105/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 11 Jul 2016 04:22:52 +0000 (13:22 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 22 Jul 2016 05:23:22 +0000 (14:23 +0900)
Change-Id: Ib7d5482cf31fef8983f6a7397bad14e71120eb88
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
ism/extras/efl_immodule/isf_imf_context.cpp

index adee47e..830cb25 100644 (file)
@@ -660,6 +660,7 @@ autoperiod_insert (Ecore_IMF_Context *ctx)
     Eina_Unicode *ustr = NULL;
     Ecore_IMF_Event_Delete_Surrounding ev;
     char *fullstop_mark = NULL;
+    size_t ulen = 0;
 
     if (autoperiod_allow == EINA_FALSE)
         return;
@@ -680,7 +681,9 @@ autoperiod_insert (Ecore_IMF_Context *ctx)
     ustr = eina_unicode_utf8_to_unicode (plain_str, NULL);
     if (!ustr) goto done;
 
-    if (cursor_pos < 2) goto done;
+    ulen = eina_unicode_strlen (ustr);
+
+    if (cursor_pos < 2 || cursor_pos > (int)ulen) goto done;
 
     if (check_space_symbol (ustr[cursor_pos-1]) &&
         !(iswpunct (ustr[cursor_pos-2]) || check_space_symbol (ustr[cursor_pos-2]))) {