cedric pushed a commit to branch master.

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

commit 9c62ab525b86867664fa25749eccc51e094bbd5d
Author: Prasoon Singh <prasoon...@samsung.com>
Date:   Tue May 9 10:37:12 2017 -0700

    eina: fix for escapable charachters not getting escaped if it comes after 
'\t' or '\n'
    
    Summary:
    Escaping is not happening whenever any escapable characters is coming after
    '\t' or '\n'. It will also fix invalid read of 1 byte which happens for 
string where
    last charachter is '\t' or '\n' like "eina\t".
    
    Test Plan:
    Take a string like "eina\t ". Observe space which is followed by tab is not 
getting
    escaped.
    
    Signed-off-by: Prasoon Singh <prasoon...@samsung.com>
    
    Reviewers: shilpasingh, rajeshps, govi, cedric
    
    Reviewed By: shilpasingh
    
    Subscribers: cedric, jpeg
    
    Differential Revision: https://phab.enlightenment.org/D4847
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 AUTHORS                        |  3 ++-
 src/lib/eina/eina_str.c        | 13 ++++++++-----
 src/tests/eina/eina_test_str.c |  7 +++++++
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index c4be95a..2a705de 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -54,7 +54,8 @@ Rajeev Ranjan (Rajeev) <rajee...@samsung.com> 
<rajeev.jn...@gmail.com>
 Subodh Kumar <s7158.ku...@samsung.com>
 Michelle Legrand <legrand.miche...@outlook.com>
 Shilpa Singh <shilpa.si...@samsung.com> <shilpasing...@gmail.com>
-
+Prasoon Singh <prasoonsing...@gmail.com>
+ 
 Eet
 ---
 
diff --git a/src/lib/eina/eina_str.c b/src/lib/eina/eina_str.c
index b9f0c03..53e27d5 100644
--- a/src/lib/eina/eina_str.c
+++ b/src/lib/eina/eina_str.c
@@ -668,24 +668,27 @@ eina_str_escape(const char *str)
            {
              *d = '\\';
              d++;
+             *d = *s;
              break;
            }
          case '\n':
            {
              *d = '\\'; d++;
-             *d = 'n'; d++;
-             s++;
+             *d = 'n';
              break;
            }
          case '\t':
            {
              *d = '\\'; d++;
-             *d = 't'; d++;
-             s++;
+             *d = 't';
+             break;
+           }
+         default:
+           {
+             *d = *s;
              break;
            }
         }
-        *d = *s;
      }
    *d = 0;
    return s2;
diff --git a/src/tests/eina/eina_test_str.c b/src/tests/eina/eina_test_str.c
index 63acec9..23c8c6c 100644
--- a/src/tests/eina/eina_test_str.c
+++ b/src/tests/eina/eina_test_str.c
@@ -108,6 +108,13 @@ START_TEST(str_simple)
    free(str);
    free(ret);
 
+   str = malloc(sizeof(char) * 4);
+   strcpy(str, "a\t ");
+   ret = eina_str_escape(str);
+   fail_if(!eina_streq(ret, "a\\t\\ "));
+   free(str);
+   free(ret);
+
    eina_shutdown();
 }
 END_TEST

-- 


Reply via email to