diff options
author | Jeremy Allison <jra@samba.org> | 2001-06-23 07:22:16 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-06-23 07:22:16 +0000 |
commit | 37eb0d6c74ce158b1cc268cea446b33789550048 (patch) | |
tree | 53db3f7b7c381be854d8493ef7ac3e353bd640e4 /source3/lib/util_str.c | |
parent | 7133aed083612480a94a7b61d6a0a0308c304b6e (diff) | |
download | samba-37eb0d6c74ce158b1cc268cea446b33789550048.tar.gz samba-37eb0d6c74ce158b1cc268cea446b33789550048.tar.bz2 samba-37eb0d6c74ce158b1cc268cea446b33789550048.zip |
Added other_safe_chars to alpha_strcpy(). Needs testing but is a better
fix for the problem.
Jeremy.
(This used to be commit e059fffd03a1382fb2b7059b6de369d9fc765a17)
Diffstat (limited to 'source3/lib/util_str.c')
-rw-r--r-- | source3/lib/util_str.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index f1376fe0f7..1c1b31a83c 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -933,11 +933,12 @@ char *safe_strcat(char *dest, const char *src, size_t maxlength) /******************************************************************* Paranoid strcpy into a buffer of given length (includes terminating - zero. Strips out all but 'a-Z0-9' and replaces with '_'. Deliberately - does *NOT* check for multibyte characters. Don't change it ! + 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 ! ********************************************************************/ -char *alpha_strcpy(char *dest, const char *src, size_t maxlength) +char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength) { size_t len, i; @@ -955,9 +956,12 @@ char *alpha_strcpy(char *dest, const char *src, size_t maxlength) if (len >= maxlength) len = maxlength - 1; + if (!other_safe_chars) + other_safe_chars = ""; + for(i = 0; i < len; i++) { int val = (src[i] & 0xff); - if(isupper(val) ||islower(val) || isdigit(val)) + if(isupper(val) || islower(val) || isdigit(val) || strchr(other_safe_chars, val)) dest[i] = src[i]; else dest[i] = '_'; |