summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrasoon Singh <prasoon.16@samsung.com>2017-05-09 10:37:12 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-05-09 10:37:16 -0700
commit9c62ab525b86867664fa25749eccc51e094bbd5d (patch)
tree3572fabb58b07e41a3141a46c1394997865728bf
parent07024ab6c84ddadd74a7c5c08a2661af51e38997 (diff)
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.16@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 <cedric@osg.samsung.com>
-rw-r--r--AUTHORS3
-rw-r--r--src/lib/eina/eina_str.c13
-rw-r--r--src/tests/eina/eina_test_str.c7
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) <rajeev.r@samsung.com> <rajeev.jnnce@gmail.com>
54Subodh Kumar <s7158.kumar@samsung.com> 54Subodh Kumar <s7158.kumar@samsung.com>
55Michelle Legrand <legrand.michelle@outlook.com> 55Michelle Legrand <legrand.michelle@outlook.com>
56Shilpa Singh <shilpa.singh@samsung.com> <shilpasingh.o@gmail.com> 56Shilpa Singh <shilpa.singh@samsung.com> <shilpasingh.o@gmail.com>
57 57Prasoon Singh <prasoonsingh16@gmail.com>
58
58Eet 59Eet
59--- 60---
60 61
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)
668 { 668 {
669 *d = '\\'; 669 *d = '\\';
670 d++; 670 d++;
671 *d = *s;
671 break; 672 break;
672 } 673 }
673 case '\n': 674 case '\n':
674 { 675 {
675 *d = '\\'; d++; 676 *d = '\\'; d++;
676 *d = 'n'; d++; 677 *d = 'n';
677 s++;
678 break; 678 break;
679 } 679 }
680 case '\t': 680 case '\t':
681 { 681 {
682 *d = '\\'; d++; 682 *d = '\\'; d++;
683 *d = 't'; d++; 683 *d = 't';
684 s++; 684 break;
685 }
686 default:
687 {
688 *d = *s;
685 break; 689 break;
686 } 690 }
687 } 691 }
688 *d = *s;
689 } 692 }
690 *d = 0; 693 *d = 0;
691 return s2; 694 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)
108 free(str); 108 free(str);
109 free(ret); 109 free(ret);
110 110
111 str = malloc(sizeof(char) * 4);
112 strcpy(str, "a\t ");
113 ret = eina_str_escape(str);
114 fail_if(!eina_streq(ret, "a\\t\\ "));
115 free(str);
116 free(ret);
117
111 eina_shutdown(); 118 eina_shutdown();
112} 119}
113END_TEST 120END_TEST