cedric pushed a commit to branch master.

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

commit b457dff840ff1e0e1c278b9aa492628f025422c3
Author: Andrii Kroitor <an.kroi...@samsung.com>
Date:   Thu Jan 29 21:17:00 2015 +0100

    evil: fix SEGFAULT in strcasestr
    
    Summary:
    there was an unsigned int underflow.
    
    @fix
    
    Test Plan: strcasestr("a", "bbb");
    
    Reviewers: cedric, raster, Hermet, seoz
    
    Subscribers: cedric, reutskiy.v.v
    
    Differential Revision: https://phab.enlightenment.org/D1909
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/lib/evil/evil_string.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lib/evil/evil_string.c b/src/lib/evil/evil_string.c
index 1112172..7d7d88c 100644
--- a/src/lib/evil/evil_string.c
+++ b/src/lib/evil/evil_string.c
@@ -58,7 +58,9 @@ char *strcasestr(const char *haystack, const char *needle)
      return NULL;
 
    length_needle = strlen(needle);
-   length_haystack = strlen(haystack) - length_needle + 1;
+   length_haystack = strlen(haystack);
+   if (length_haystack < length_needle) return NULL;
+   length_haystack = length_haystack - length_needle + 1;
 
    for (i = 0; i < length_haystack; i++)
      {

-- 


Reply via email to