From 06f053bd7c74f0362fe15d2c2ccb76bdc39d668d Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Thu, 29 May 2003 01:41:56 +0000 Subject: 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) --- source3/param/loadparm.c | 30 ++++++++++-------------------- 1 file 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); } -- cgit