[SCM] Samba Shared Repository - branch v3-0-test updated -
release-3-0-28-98-gdb905d9
Volker Lendecke
vl at samba.org
Tue Jan 22 11:07:15 GMT 2008
The branch, v3-0-test has been updated
via db905d9c4248c0051266ef0995dce077c1a33dd3 (commit)
from 7ff5a123b4fd80d66da92f34062174573a4f9725 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-0-test
- Log -----------------------------------------------------------------
commit db905d9c4248c0051266ef0995dce077c1a33dd3
Author: Volker Lendecke <vl at samba.org>
Date: Tue Jan 22 11:54:31 2008 +0100
Copy the 3.2 version of string_replace to 3.0
There are several callers in 3.0 that don't give a pstring to string_replace,
thus it will end up in segfaults like the one reported by Sergio Pires
<suporte at grupovdl.com.br> on samba at samba.org. The 3.2 version of string_replace
does not have the pstring assumption anymore.
Jeremy, Jerry, please check!
Thanks,
Volker
-----------------------------------------------------------------------
Summary of changes:
source/lib/util_str.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/lib/util_str.c b/source/lib/util_str.c
index 52cdbfc..b734495 100644
--- a/source/lib/util_str.c
+++ b/source/lib/util_str.c
@@ -394,7 +394,11 @@ BOOL strisnormal(const char *s, int case_default)
NOTE: oldc and newc must be 7 bit characters
**/
-void string_replace( pstring s, char oldc, char newc )
+/**
+ String replace.
+ NOTE: oldc and newc must be 7 bit characters
+**/
+void string_replace( char *s, char oldc, char newc )
{
char *p;
@@ -406,8 +410,9 @@ void string_replace( pstring s, char oldc, char newc )
for (p = s; *p; p++) {
if (*p & 0x80) /* mb string - slow path. */
break;
- if (*p == oldc)
+ if (*p == oldc) {
*p = newc;
+ }
}
if (!*p)
@@ -418,9 +423,18 @@ void string_replace( pstring s, char oldc, char newc )
/* With compose characters we must restart from the beginning. JRA. */
p = s;
#endif
- push_ucs2(NULL, tmpbuf, p, sizeof(tmpbuf), STR_TERMINATE);
- string_replace_w(tmpbuf, UCS2_CHAR(oldc), UCS2_CHAR(newc));
- pull_ucs2(NULL, p, tmpbuf, -1, sizeof(tmpbuf), STR_TERMINATE);
+
+ while (*p) {
+ size_t c_size;
+ next_codepoint(p, &c_size);
+
+ if (c_size == 1) {
+ if (*p == oldc) {
+ *p = newc;
+ }
+ }
+ p += c_size;
+ }
}
/**
--
Samba Shared Repository
More information about the samba-cvs
mailing list