libsmb: Fix two CIDs for NULL dereference
authorVolker Lendecke <vl@samba.org>
Tue, 7 Jun 2016 08:07:21 +0000 (10:07 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 7 Jun 2016 16:31:30 +0000 (18:31 +0200)
This whole area is a known-to-be-broken mess, but this patch should fix
the immediate crash

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jun  7 18:31:30 CEST 2016 on sn-devel-144

source3/libsmb/libsmb_server.c

index 06c0211fa675611a22b6aea20bbbcd7ad524ac85..eb4d5d2963fb599a0bde523f217d75871043b6bc 100644 (file)
@@ -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);