1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-08 04:58:40 +03:00

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)
This commit is contained in:
Andrew Bartlett 2004-03-09 09:56:33 +00:00
parent c9b7cbbfa5
commit 151faf6935

View File

@ -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) {