diff --git a/source/smbd/uid.c b/source/smbd/uid.c index bec820b..0aefc75 100644 --- a/source/smbd/uid.c +++ b/source/smbd/uid.c @@ -153,6 +153,7 @@ static bool check_user_ok(connection_struct *conn, /**************************************************************************** Clear a vuid out of the connection's vuid cache + This is only called on SMBulogoff. ****************************************************************************/ void conn_clear_vuid_cache(connection_struct *conn, uint16_t vuid) @@ -166,11 +167,20 @@ void conn_clear_vuid_cache(connection_struct *conn, uint16_t vuid) if (ent->vuid == vuid) { ent->vuid = UID_FIELD_INVALID; - /* Ensure we're not freeing an active pointer. */ - if (conn->server_info == ent->server_info) { - conn->server_info = NULL; + /* + * We need to keep conn->server_info around + * if it's equal to ent->server_info as a SMBulogoff + * if often followed by a SMBtdis (with an invalid + * vuid). The debug code (or regular code in + * vfs_full_audit) wants to refer to the + * conn->server_info pointer to print debug + * statements. Ass everything is hung off the + * conn pointer as a talloc context we're not + * leaking memory here. See bug #6315. JRA. + */ + if (conn->server_info != ent->server_info) { + TALLOC_FREE(ent->server_info); } - TALLOC_FREE(ent->server_info); ent->read_only = False; ent->admin_user = False; }