Bug and Fix - Follow Up
Matt Roberts, GRDA
mattro at grda.com
Wed Dec 18 03:02:00 GMT 2002
Developers,
In my search for the cause of the behavior seen in my earlier post,
I traced the function call path to these two interesting functions,
int source/lib/util.c at about line 133:
BOOL set_global_scope(const char *scope)
{
SAFE_FREE(smb_scope);
smb_scope = strdup(scope);
if (!smb_scope)
return False;
strupper(smb_scope);
return True;
}
const char *global_scope(void)
{
return smb_scope;
}
Since the latter function returns the string 'smb_scope', regardless
of what is in it, wouldn't the first function protect against being
set to a NULL value by rewriting it similar to this?
BOOL set_global_scope(const char *scope)
{
SAFE_FREE(smb_scope);
if (!smb_scope) {
smb_scope = strdup("");
return False;
}
smb_scope = strdup(scope);
strupper(smb_scope);
return True;
}
That way, you still get the 'False' return, but you also keep a valid value
in the pointer if the arg is NULL. Or do you think the problem is more in
the way the default is setup in the configuration code?
Just a thought.
Thanks again,
Matt
More information about the samba-technical
mailing list