summaryrefslogtreecommitdiffstats
path: root/source/lib/util_str.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-06-23 07:21:25 +0000
committerJeremy Allison <jra@samba.org>2001-06-23 07:21:25 +0000
commit2e7e09331a445117c52b007dba8a7093899a331d (patch)
treedfa67649422bf714ac8314ecb8779de95566d749 /source/lib/util_str.c
parentc0782c1a365a26ebba584539cd58cd28304f76f1 (diff)
downloadsamba-2e7e09331a445117c52b007dba8a7093899a331d.tar.gz
samba-2e7e09331a445117c52b007dba8a7093899a331d.tar.xz
samba-2e7e09331a445117c52b007dba8a7093899a331d.zip
Added "other_safe_chars" to alpha_strcpy(). Needs testing but is a better
API fix for the problem. Jeremy.
Diffstat (limited to 'source/lib/util_str.c')
-rw-r--r--source/lib/util_str.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/source/lib/util_str.c b/source/lib/util_str.c
index 50c6605d5c3..07c91805cc7 100644
--- a/source/lib/util_str.c
+++ b/source/lib/util_str.c
@@ -918,11 +918,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;
@@ -940,9 +941,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] = '_';