From 08a78662e9406fbc23db059f30b4e55392ee7332 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 7 Jun 2016 10:07:21 +0200 Subject: [PATCH] libsmb: Fix two CIDs for NULL dereference This whole area is a known-to-be-broken mess, but this patch should fix the immediate crash Signed-off-by: Volker Lendecke Reviewed-by: Michael Adam Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Tue Jun 7 18:31:30 CEST 2016 on sn-devel-144 --- source3/libsmb/libsmb_server.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 06c0211fa67..eb4d5d2963f 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -121,14 +121,20 @@ SMBC_call_auth_fn(TALLOC_CTX *ctx, char **pp_username, char **pp_password) { - fstring workgroup; - fstring username; - fstring password; + fstring workgroup = { 0 }; + fstring username = { 0 }; + fstring password = { 0 }; smbc_get_auth_data_with_context_fn auth_with_context_fn; - strlcpy(workgroup, *pp_workgroup, sizeof(workgroup)); - strlcpy(username, *pp_username, sizeof(username)); - strlcpy(password, *pp_password, sizeof(password)); + if (*pp_workgroup != NULL) { + strlcpy(workgroup, *pp_workgroup, sizeof(workgroup)); + } + if (*pp_username != NULL) { + strlcpy(username, *pp_username, sizeof(username)); + } + if (*pp_password != NULL) { + strlcpy(password, *pp_password, sizeof(password)); + } /* See if there's an authentication with context function provided */ auth_with_context_fn = smbc_getFunctionAuthDataWithContext(context); -- 2.47.2