summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
authorJim McDonough <jmcd@samba.org>2003-05-29 01:41:56 +0000
committerJim McDonough <jmcd@samba.org>2003-05-29 01:41:56 +0000
commit06f053bd7c74f0362fe15d2c2ccb76bdc39d668d (patch)
tree44b7900d01d8e9eab3b83977488c84a6bc6890ea /source3/param
parent3d1c9c75812aa47c60d6d912e97a76d6b7e7895d (diff)
downloadsamba-06f053bd7c74f0362fe15d2c2ccb76bdc39d668d.tar.gz
samba-06f053bd7c74f0362fe15d2c2ccb76bdc39d668d.tar.bz2
samba-06f053bd7c74f0362fe15d2c2ccb76bdc39d668d.zip
Fix bugzilla #117: winbindd looping on 100+char username
This modifies lp_string to use alloc_sub_basic to allow any length substitution instead of fixed at 100 chars. (This used to be commit cad9d88a6125369a43f710a8870300b6f40d899c)
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/loadparm.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 420a15c4df..1d0bed0695 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1496,8 +1496,7 @@ void lp_talloc_free(void)
static char *lp_string(const char *s)
{
- size_t len = s ? strlen(s) : 0;
- char *ret;
+ char *ret, *tmpstr;
/* The follow debug is useful for tracking down memory problems
especially if you have an inner loop that is calling a lp_*()
@@ -1511,25 +1510,16 @@ static char *lp_string(const char *s)
if (!lp_talloc)
lp_talloc = talloc_init("lp_talloc");
- ret = (char *)talloc(lp_talloc, len + 100); /* leave room for substitution */
-
- if (!ret)
- return NULL;
-
- /* Note: safe_strcpy touches len+1 bytes, but we allocate 100
- * extra bytes so we're OK. */
-
- if (!s)
- *ret = 0;
- else
- safe_strcpy(ret, s, len+99);
-
- if (trim_string(ret, "\"", "\"")) {
- if (strchr(ret,'"') != NULL)
- safe_strcpy(ret, s, len+99);
+ tmpstr = alloc_sub_basic(current_user_info.smb_name, s);
+ if (trim_string(tmpstr, "\"", "\"")) {
+ if (strchr(tmpstr,'"') != NULL) {
+ SAFE_FREE(tmpstr);
+ tmpstr = alloc_sub_basic(current_user_info.smb_name,s);
+ }
}
-
- standard_sub_basic(current_user_info.smb_name,ret,len+100);
+ ret = talloc_strdup(lp_talloc, tmpstr);
+ SAFE_FREE(tmpstr);
+
return (ret);
}