Ignore:
Timestamp:
Jun 17, 2009, 2:19:52 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.3 branch to 3.3.5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/smbd/uid.c

    r224 r274  
    5555}
    5656
     57/****************************************************************************
     58 talloc free the conn->server_info if not used in the vuid cache.
     59****************************************************************************/
     60
     61static void free_conn_server_info_if_unused(connection_struct *conn)
     62{
     63        unsigned int i;
     64
     65        for (i = 0; i < VUID_CACHE_SIZE; i++) {
     66                struct vuid_cache_entry *ent;
     67                ent = &conn->vuid_cache.array[i];
     68                if (ent->vuid != UID_FIELD_INVALID &&
     69                                conn->server_info == ent->server_info) {
     70                        return;
     71                }
     72        }
     73        /* Not used, safe to free. */
     74        TALLOC_FREE(conn->server_info);
     75}
     76
    5777/*******************************************************************
    5878 Check if a username is OK.
     
    7898                        ent = &conn->vuid_cache.array[i];
    7999                        if (ent->vuid == vuid) {
     100                                free_conn_server_info_if_unused(conn);
    80101                                conn->server_info = ent->server_info;
    81102                                conn->read_only = ent->read_only;
     
    143164                ent->read_only = readonly_share;
    144165                ent->admin_user = admin_user;
     166                free_conn_server_info_if_unused(conn);
    145167                conn->server_info = ent->server_info;
    146168        }
     
    154176/****************************************************************************
    155177 Clear a vuid out of the connection's vuid cache
     178 This is only called on SMBulogoff.
    156179****************************************************************************/
    157180
     
    167190                if (ent->vuid == vuid) {
    168191                        ent->vuid = UID_FIELD_INVALID;
    169                         /* Ensure we're not freeing an active pointer. */
     192                        /*
     193                         * We need to keep conn->server_info around
     194                         * if it's equal to ent->server_info as a SMBulogoff
     195                         * is often followed by a SMBtdis (with an invalid
     196                         * vuid). The debug code (or regular code in
     197                         * vfs_full_audit) wants to refer to the
     198                         * conn->server_info pointer to print debug
     199                         * statements. Theoretically this is a bug,
     200                         * as once the vuid is gone the server_info
     201                         * on the conn struct isn't valid any more,
     202                         * but there's enough code that assumes
     203                         * conn->server_info is never null that
     204                         * it's easier to hold onto the old pointer
     205                         * until we get a new sessionsetupX.
     206                         * As everything is hung off the
     207                         * conn pointer as a talloc context we're not
     208                         * leaking memory here. See bug #6315. JRA.
     209                         */
    170210                        if (conn->server_info == ent->server_info) {
    171                                 conn->server_info = NULL;
     211                                ent->server_info = NULL;
     212                        } else {
     213                                TALLOC_FREE(ent->server_info);
    172214                        }
    173                         TALLOC_FREE(ent->server_info);
    174215                        ent->read_only = False;
    175216                        ent->admin_user = False;
Note: See TracChangeset for help on using the changeset viewer.