From 923a3a0e1ce0a89a2e9be85cc224729610092b3f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Jul 2002 23:43:33 +0000 Subject: Previous fix was incorrect. len in string_sub and all_string_sub is number of *bytes*. >= check was correct, the len=0 case needed changing to len = ls + 1. Jeremy. (This used to be commit 06a4a6d30ade5ea4d123ae640393677c9a510763) --- source3/lib/util_str.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index c1d20ffd2c..67d3b2108e 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -667,10 +667,10 @@ void string_sub(char *s,const char *pattern, const char *insert, size_t len) li = (ssize_t)strlen(insert); if (len == 0) - len = ls; + len = ls + 1; /* len is number of *bytes* */ while (lp <= ls && (p = strstr(s,pattern))) { - if (ls + (li-lp) > len) { + if (ls + (li-lp) >= len) { DEBUG(0,("ERROR: string overflow by %d in string_sub(%.50s, %d)\n", (int)(ls + (li-lp) - len), pattern, (int)len)); @@ -798,10 +798,10 @@ void all_string_sub(char *s,const char *pattern,const char *insert, size_t len) return; if (len == 0) - len = ls; + len = ls + 1; /* len is number of *bytes* */ while (lp <= ls && (p = strstr(s,pattern))) { - if (ls + (li-lp) > len) { + if (ls + (li-lp) >= len) { DEBUG(0,("ERROR: string overflow by %d in all_string_sub(%.50s, %d)\n", (int)(ls + (li-lp) - len), pattern, (int)len)); -- cgit