From f85b6ee90b88c7f7b2a92c8a5f3e2ebe59c1087b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 15 Jan 2010 17:33:24 -0800 Subject: Second part of bug 7045 - Bad (non memory copying) interfaces in smbc_setXXXX calls. Protect against SMB_STRDUP of null... Jeremy. --- source3/libsmb/libsmb_setget.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source3/libsmb/libsmb_setget.c b/source3/libsmb/libsmb_setget.c index 3ef707863f..791b4cd9e4 100644 --- a/source3/libsmb/libsmb_setget.c +++ b/source3/libsmb/libsmb_setget.c @@ -40,7 +40,9 @@ void smbc_setNetbiosName(SMBCCTX *c, char * netbios_name) { SAFE_FREE(c->netbios_name); - c->netbios_name = SMB_STRDUP(netbios_name); + if (netbios_name) { + c->netbios_name = SMB_STRDUP(netbios_name); + } } /** Get the workgroup used for making connections */ @@ -55,7 +57,9 @@ void smbc_setWorkgroup(SMBCCTX *c, char * workgroup) { SAFE_FREE(c->workgroup); - c->workgroup = SMB_STRDUP(workgroup); + if (workgroup) { + c->workgroup = SMB_STRDUP(workgroup); + } } /** Get the username used for making connections */ @@ -70,7 +74,9 @@ void smbc_setUser(SMBCCTX *c, char * user) { SAFE_FREE(c->user); - c->user = SMB_STRDUP(user); + if (user) { + c->user = SMB_STRDUP(user); + } } /** Get the debug level */ -- cgit