summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-07-18 23:43:33 +0000
committerJeremy Allison <jra@samba.org>2002-07-18 23:43:33 +0000
commit923a3a0e1ce0a89a2e9be85cc224729610092b3f (patch)
tree78ba5b330e8fbd5163b31637582a3f545f5f7bed /source3/lib
parent7f98456fb3002623773b84c9a785ff6b3bc03b2f (diff)
downloadsamba-923a3a0e1ce0a89a2e9be85cc224729610092b3f.tar.gz
samba-923a3a0e1ce0a89a2e9be85cc224729610092b3f.tar.bz2
samba-923a3a0e1ce0a89a2e9be85cc224729610092b3f.zip
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)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_str.c8
1 files changed, 4 insertions, 4 deletions
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));