summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@suse.de>2011-03-28 15:59:32 -0700
committerJeremy Allison <jra@samba.org>2011-03-29 01:35:23 +0200
commitdb966efe8a4cc065f4e998bbed8a9d2c0ec2c976 (patch)
treeecafa9a1c8e1e6bad3215bfb61e09ef03f1b83a0 /source3
parente0681441afff8876b651d754eefb1d84470e8640 (diff)
downloadsamba-db966efe8a4cc065f4e998bbed8a9d2c0ec2c976.tar.gz
samba-db966efe8a4cc065f4e998bbed8a9d2c0ec2c976.tar.bz2
samba-db966efe8a4cc065f4e998bbed8a9d2c0ec2c976.zip
=?UTF-8?q?alpha=5Fstrcpy()=20is=20a=20utility=20function=20which=20reportedly:
=20Strips=20out=20all=20but=20'a-Z0-9'=20and=20the=20character=20in=20other=5Fsafe=5Fchars=20and =20replaces=20with=20'=5F'. =20This=20statement=20does=20not=20currently=20hold=20true=20in=20all=20cases=20(e.g.=20src=20=3D =20"=D0=A2=D0=90=D0=9D=D0=A6=D0=95=D0=92=D0=90=D0=A2=D0=AC").?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util_str.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 1996174261..7b50717463 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -506,7 +506,9 @@ char *safe_strcat_fn(char *dest,
Paranoid strcpy into a buffer of given length (includes terminating
zero. Strips out all but 'a-Z0-9' and the character in other_safe_chars
and replaces with '_'. Deliberately does *NOT* check for multibyte
- characters. Don't change it !
+ characters. Treats src as an array of bytes, not as a multibyte
+ string. Any byte >0x7f is automatically converted to '_'.
+ other_safe_chars must also contain an ascii string (bytes<0x7f).
**/
char *alpha_strcpy(char *dest,
@@ -534,8 +536,12 @@ char *alpha_strcpy(char *dest,
for(i = 0; i < len; i++) {
int val = (src[i] & 0xff);
- if (isupper_ascii(val) || islower_ascii(val) ||
- isdigit(val) || strchr_m(other_safe_chars, val))
+ if (val > 0x7f) {
+ dest[i] = '_';
+ continue;
+ }
+ if (isupper(val) || islower(val) ||
+ isdigit(val) || strchr(other_safe_chars, val))
dest[i] = src[i];
else
dest[i] = '_';