r23779: Change from v2 or later to v3 or later.
[ira/wip.git] / source3 / libsmb / samlogon_cache.c
index 61dddb62fd3a21e520994c3a25d4367ea8d7c767..c58f3b212df525685ebfd3b53e57b20fe0855137 100644 (file)
@@ -8,7 +8,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -59,7 +59,6 @@ BOOL netsamlogon_cache_shutdown(void)
 ***********************************************************************/
 void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, NET_USER_INFO_3 *user)
 {
-       TDB_DATA key;
        BOOL got_tdb = False;
        DOM_SID sid;
        fstring key_str, sid_string;
@@ -93,7 +92,7 @@ void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, NET_USER_INFO_3 *user)
 
        fstr_sprintf(key_str, "UG/%s", sid_to_string(sid_string, &sid));
 
-       DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key.dptr));
+       DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key_str));
 
        tdb_delete(tdb, string_tdb_data(key_str));
 
@@ -193,21 +192,23 @@ NET_USER_INFO_3* netsamlogon_cache_get( TALLOC_CTX *mem_ctx, const DOM_SID *user
        data = tdb_fetch_bystring( netsamlogon_tdb, keystr );
        
        if ( data.dptr ) {
-               
-               if ( (user = SMB_MALLOC_P(NET_USER_INFO_3)) == NULL )
+
+               user = TALLOC_ZERO_P(mem_ctx, NET_USER_INFO_3);
+               if (user == NULL) {
                        return NULL;
-                       
+               }
+
                prs_init( &ps, 0, mem_ctx, UNMARSHALL );
                prs_give_memory( &ps, (char *)data.dptr, data.dsize, True );
                
                if ( !prs_uint32( "timestamp", &ps, 0, &t ) ) {
                        prs_mem_free( &ps );
-                       SAFE_FREE(user);
+                       TALLOC_FREE(user);
                        return False;
                }
                
                if ( !net_io_user_info3("", user, &ps, 0, 3, 0) ) {
-                       SAFE_FREE( user );
+                       TALLOC_FREE( user );
                }
                        
                prs_mem_free( &ps );
@@ -226,7 +227,7 @@ NET_USER_INFO_3* netsamlogon_cache_get( TALLOC_CTX *mem_ctx, const DOM_SID *user
                if ( (time_diff < 0 ) || (time_diff > lp_winbind_cache_time()) ) {
                        DEBUG(10,("netsamlogon_cache_get: cache entry expired \n"));
                        tdb_delete( netsamlogon_tdb, key );
-                       SAFE_FREE( user );
+                       TALLOC_FREE( user );
                }
 #endif
        }
@@ -248,7 +249,6 @@ BOOL netsamlogon_cache_have(const DOM_SID *user_sid)
        result = (user != NULL);
 
        talloc_destroy(mem_ctx);
-       SAFE_FREE(user);
 
        return result;
 }