The branch, master has been updated via d1d2a03d73b s3:utils: Initialize the memcache for smbpasswd via 89e376c69a3 s3:util: Add gfree_memcache() to gfree_all() via cdcaac148f3 lib:util: Add a gfree_memcache() via b3234c55743 s3:passdb: Do not leak memory if memcache add fails via 842d2eca91b lib:util: Add boolean return type for memcache_add_talloc() via 200a5b7617d lib:util: Add boolean return type for memcache_add() via a2a31519fb5 s3:utils: Initialize row variable in wspsearch from 0bb67a3a7e7 python: silos: add support for allowed to authenticate from silo shortcut
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit d1d2a03d73b376d54aa6d010e521282746b068fe Author: Andreas Schneider <a...@samba.org> Date: Thu Oct 26 14:37:29 2023 +0200 s3:utils: Initialize the memcache for smbpasswd Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org> Autobuild-Date(master): Fri Oct 27 06:51:48 UTC 2023 on atb-devel-224 commit 89e376c69a39175684dfb7b7cbaea9dcd996dd63 Author: Andreas Schneider <a...@samba.org> Date: Thu Oct 26 14:36:02 2023 +0200 s3:util: Add gfree_memcache() to gfree_all() Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit cdcaac148f3b42d8bdf415a5ce0ef77031c2d0f5 Author: Andreas Schneider <a...@samba.org> Date: Thu Oct 26 14:35:44 2023 +0200 lib:util: Add a gfree_memcache() Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit b3234c55743d8329ba1d387943865b23233e22c7 Author: Andreas Schneider <a...@samba.org> Date: Thu Oct 26 14:28:19 2023 +0200 s3:passdb: Do not leak memory if memcache add fails Indirect leak of 496 byte(s) in 1 object(s) allocated from: #0 0x7ffb062dc03f in malloc (/lib64/libasan.so.8+0xdc03f) (BuildId: 3e1694ad218c99a8b1b69231666a27df63cf19d0) #1 0x7ffb06025b3e in __talloc_with_prefix ../../lib/talloc/talloc.c:783 #2 0x7ffb06027512 in __talloc ../../lib/talloc/talloc.c:825 #3 0x7ffb06027512 in _talloc_named_const ../../lib/talloc/talloc.c:982 #4 0x7ffb06027512 in _talloc_zero ../../lib/talloc/talloc.c:2421 #5 0x7ffb05a0332c in samu_new ../../source3/passdb/passdb.c:63 #6 0x7ffb05a2031f in pdb_getsampwnam ../../source3/passdb/pdb_interface.c:351 #7 0x7ffb05a0540b in local_password_change ../../source3/passdb/passdb.c:752 #8 0x56291ddd4b8b in password_change ../../source3/utils/smbpasswd.c:273 #9 0x56291ddd5b59 in process_root ../../source3/utils/smbpasswd.c:478 #10 0x56291ddd5b59 in main ../../source3/utils/smbpasswd.c:661 #11 0x7ffb024281af in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 842d2eca91be3682ba7194501cafa6a0c2152be6 Author: Andreas Schneider <a...@samba.org> Date: Thu Oct 26 14:26:57 2023 +0200 lib:util: Add boolean return type for memcache_add_talloc() Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 200a5b7617d6f12a3907702bf0473f7ddda1c53b Author: Andreas Schneider <a...@samba.org> Date: Thu Oct 26 14:26:26 2023 +0200 lib:util: Add boolean return type for memcache_add() Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit a2a31519fb5f0313c6dcf3b251180530c9006802 Author: Andreas Schneider <a...@samba.org> Date: Thu Oct 26 14:09:33 2023 +0200 s3:utils: Initialize row variable in wspsearch ../../source3/utils/wspsearch.c:331:25: error: ‘row’ may be used uninitialized [-Werror=maybe-uninitialized] 331 | *rows_processed = row; | ~~~~~~~~~~~~~~~~^~~~~ Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> ----------------------------------------------------------------------- Summary of changes: lib/util/memcache.c | 24 ++++++++++++++++-------- lib/util/memcache.h | 6 ++++-- source3/lib/util.c | 3 +++ source3/passdb/pdb_interface.c | 10 +++++++--- source3/utils/smbpasswd.c | 9 +++++++++ source3/utils/wspsearch.c | 2 +- 6 files changed, 40 insertions(+), 14 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/util/memcache.c b/lib/util/memcache.c index 7b0b27eaddb..98e317c66fb 100644 --- a/lib/util/memcache.c +++ b/lib/util/memcache.c @@ -265,7 +265,7 @@ void memcache_delete(struct memcache *cache, enum memcache_number n, memcache_delete_element(cache, e); } -void memcache_add(struct memcache *cache, enum memcache_number n, +bool memcache_add(struct memcache *cache, enum memcache_number n, DATA_BLOB key, DATA_BLOB value) { struct memcache_element *e; @@ -278,11 +278,11 @@ void memcache_add(struct memcache *cache, enum memcache_number n, cache = global_cache; } if (cache == NULL) { - return; + return false; } if (key.length == 0) { - return; + return false; } e = memcache_find(cache, n, key); @@ -312,7 +312,7 @@ void memcache_add(struct memcache *cache, enum memcache_number n, memcpy(&mtv, cache_value.data, sizeof(mtv)); cache->size += mtv.len; } - return; + return true; } memcache_delete_element(cache, e); @@ -323,7 +323,7 @@ void memcache_add(struct memcache *cache, enum memcache_number n, e = talloc_size(cache, element_size); if (e == NULL) { DEBUG(0, ("talloc failed\n")); - return; + return false; } talloc_set_type(e, struct memcache_element); @@ -363,9 +363,11 @@ void memcache_add(struct memcache *cache, enum memcache_number n, cache->size += mtv.len; } memcache_trim(cache, e); + + return true; } -void memcache_add_talloc(struct memcache *cache, enum memcache_number n, +bool memcache_add_talloc(struct memcache *cache, enum memcache_number n, DATA_BLOB key, void *pptr) { struct memcache_talloc_value mtv; @@ -375,12 +377,13 @@ void memcache_add_talloc(struct memcache *cache, enum memcache_number n, cache = global_cache; } if (cache == NULL) { - return; + return false; } mtv.len = talloc_total_size(*ptr); mtv.ptr = talloc_move(cache, ptr); - memcache_add(cache, n, key, data_blob_const(&mtv, sizeof(mtv))); + + return memcache_add(cache, n, key, data_blob_const(&mtv, sizeof(mtv))); } void memcache_flush(struct memcache *cache, enum memcache_number n) @@ -457,3 +460,8 @@ void memcache_flush(struct memcache *cache, enum memcache_number n) node = next; } } + +void gfree_memcache(void) +{ + TALLOC_FREE(global_cache); +} diff --git a/lib/util/memcache.h b/lib/util/memcache.h index 803af813025..6986760b8ce 100644 --- a/lib/util/memcache.h +++ b/lib/util/memcache.h @@ -68,7 +68,7 @@ void memcache_set_global(struct memcache *cache); * Add a data blob to the cache */ -void memcache_add(struct memcache *cache, enum memcache_number n, +bool memcache_add(struct memcache *cache, enum memcache_number n, DATA_BLOB key, DATA_BLOB value); /* @@ -82,7 +82,7 @@ void memcache_add(struct memcache *cache, enum memcache_number n, * talloc objects in the cache types. */ -void memcache_add_talloc(struct memcache *cache, enum memcache_number n, +bool memcache_add_talloc(struct memcache *cache, enum memcache_number n, DATA_BLOB key, void *ptr); /* @@ -114,4 +114,6 @@ void *memcache_lookup_talloc(struct memcache *cache, enum memcache_number n, void memcache_flush(struct memcache *cache, enum memcache_number n); +void gfree_memcache(void); + #endif diff --git a/source3/lib/util.c b/source3/lib/util.c index b6305da91ed..f891842a6b7 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -30,6 +30,7 @@ #include "system/passwd.h" #include "system/filesys.h" #include "lib/util/server_id.h" +#include "lib/util/memcache.h" #include "util_tdb.h" #include "ctdbd_conn.h" #include "../lib/util/util_pw.h" @@ -71,6 +72,8 @@ void gfree_all( void ) gfree_charcnv(); gfree_interfaces(); gfree_debugsyms(); + gfree_memcache(); + } /******************************************************************* diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index cee90d9ff79..d3648f155ed 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -360,9 +360,13 @@ bool pdb_getsampwnam(struct samu *sam_acct, const char *username) user_sid = pdb_get_user_sid(for_cache); - memcache_add_talloc(NULL, PDB_GETPWSID_CACHE, - data_blob_const(user_sid, sizeof(*user_sid)), - &for_cache); + ok = memcache_add_talloc(NULL, + PDB_GETPWSID_CACHE, + data_blob_const(user_sid, sizeof(*user_sid)), + &for_cache); + if (!ok) { + TALLOC_FREE(for_cache); + } return True; } diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index 950aaff67da..f2c5dfd2b0f 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -27,6 +27,7 @@ #include "passwd_proto.h" #include "lib/util/string_wrappers.h" #include "lib/param/param.h" +#include "lib/util/memcache.h" /* * Next two lines needed for SunOS and don't @@ -620,9 +621,17 @@ int main(int argc, char **argv) { TALLOC_CTX *frame = talloc_stackframe(); struct loadparm_context *lp_ctx = NULL; + struct memcache *mcache = NULL; int local_flags = 0; int ret; + mcache = memcache_init(NULL, 0); + if (mcache == NULL) { + fprintf(stderr, "%s: memcache_init failed\n", __location__); + return 1; + } + memcache_set_global(mcache); + #if defined(HAVE_SET_AUTH_PARAMETERS) set_auth_parameters(argc, argv); #endif /* HAVE_SET_AUTH_PARAMETERS */ diff --git a/source3/utils/wspsearch.c b/source3/utils/wspsearch.c index 3650fe12f34..aa088f7c13a 100644 --- a/source3/utils/wspsearch.c +++ b/source3/utils/wspsearch.c @@ -256,7 +256,7 @@ static NTSTATUS print_rowsreturned( uint32_t *rows_processed) { NTSTATUS status; - int row; + uint32_t row = 0; TALLOC_CTX *local_ctx = NULL; struct wsp_cbasestoragevariant **rowsarray = NULL; enum ndr_err_code err; -- Samba Shared Repository