summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2004-03-09 09:56:33 +0000
committerAndrew Bartlett <abartlet@samba.org>2004-03-09 09:56:33 +0000
commit151faf6935d54efcc3b5bcf8e60419b490ac460d (patch)
tree4796007272c7ae72366c9b392ee70fa7c5f74ccb /source3/lib
parentc9b7cbbfa572512cd0348817965b99fd1df01285 (diff)
downloadsamba-151faf6935d54efcc3b5bcf8e60419b490ac460d.tar.gz
samba-151faf6935d54efcc3b5bcf8e60419b490ac460d.tar.bz2
samba-151faf6935d54efcc3b5bcf8e60419b490ac460d.zip
JRA's recent strstr_m work really badly broke our string_sub code.
For example: strstr_m("%v foo bar", "%v") would fail... only strstr_m("foo %v", "%v") could work. I wonder what else this broke... Fix is to move to using strncmp() inside the strstr_m function. Tested on ASCII only. Andrew Bartlett (This used to be commit 44d304f84c4ba5a832d5e3848ae0d04d5438ac15)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_str.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index cad0df48a4..7f3c30f61e 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -1306,6 +1306,9 @@ char *strstr_m(const char *src, const char *findstr)
char *s2;
char *retp;
+ size_t findstr_len = 0;
+ size_t find_w_len;
+
/* Samba does single character findstr calls a *lot*. */
if (findstr[1] == '\0')
return strchr_m(src, *findstr);
@@ -1316,7 +1319,10 @@ char *strstr_m(const char *src, const char *findstr)
for (s = src; *s && !(((unsigned char)s[0]) & 0x80); s++) {
if (*s == *findstr) {
- if (strcmp(s, findstr) == 0) {
+ if (!findstr_len)
+ findstr_len = strlen(findstr);
+
+ if (strncmp(s, findstr, findstr_len) == 0) {
return (char *)s;
}
}
@@ -1341,8 +1347,10 @@ char *strstr_m(const char *src, const char *findstr)
return NULL;
}
+ find_w_len = strlen_w(find_w);
+
for (p = src_w; (p = strchr_w(p, *find_w)) != NULL; p++) {
- if (strcmp_w(p, find_w) == 0)
+ if (strncmp_w(p, find_w, find_w_len) == 0)
break;
}
if (!p) {