diff options
author | Jeremy Allison <jra@samba.org> | 2008-11-06 20:48:13 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2008-11-06 20:48:13 -0800 |
commit | 8962be69c700224983af4effd2cd086f7f5800b0 (patch) | |
tree | ad2149c31ca5102a213a13a75cd511b11c64d812 /source3/utils | |
parent | 7ae625345536572aa946f0715542a5cf2dbc2169 (diff) | |
download | samba-8962be69c700224983af4effd2cd086f7f5800b0.tar.gz samba-8962be69c700224983af4effd2cd086f7f5800b0.tar.xz samba-8962be69c700224983af4effd2cd086f7f5800b0.zip |
Make us clean under valgrind --leak-check=full by using talloc_autofree_context() instead of NULL.
Remove the code in memcache that does a TALLOC_FREE on stored pointers. That's a disaster waiting
to happen. If you're storing talloc'ed pointers, you can't know their lifecycle and they should
be deleted when their parent context is deleted, so freeing them at some arbitrary point later
will be a double-free.
Jeremy.
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_sam.c | 2 | ||||
-rw-r--r-- | source3/utils/pdbedit.c | 4 | ||||
-rw-r--r-- | source3/utils/smbpasswd.c | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index ce132131f73..e8ebb602057 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -1735,7 +1735,7 @@ doma_done: d_printf("Checking Guest's group.\n"); - pwd = getpwnam_alloc(NULL, lp_guestaccount()); + pwd = getpwnam_alloc(talloc_autofree_context(), lp_guestaccount()); if (!pwd) { d_fprintf(stderr, "Failed to find just created Guest account!\n" " Is nss properly configured?!\n"); diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index fe99b6fc9e5..50cbc43d6de 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -571,7 +571,7 @@ static int new_user (struct pdb_methods *in, const char *username, get_global_sam_sid(); - if ( !(pwd = getpwnam_alloc( NULL, username )) ) { + if ( !(pwd = getpwnam_alloc(talloc_autofree_context(), username )) ) { DEBUG(0,("Cannot locate Unix account for %s\n", username)); return -1; } @@ -675,7 +675,7 @@ static int new_machine (struct pdb_methods *in, const char *machine_in) fstrcpy(machineaccount, machinename); fstrcat(machineaccount, "$"); - if ( !(pwd = getpwnam_alloc( NULL, machineaccount )) ) { + if ( !(pwd = getpwnam_alloc(talloc_autofree_context(), machineaccount )) ) { DEBUG(0,("Cannot locate Unix account for %s\n", machineaccount)); return -1; } diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index 600fe52f0d7..d2652ad95a5 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -337,7 +337,7 @@ static int process_root(int local_flags) load_interfaces(); } - if (!user_name[0] && (pwd = getpwuid_alloc(NULL, geteuid()))) { + if (!user_name[0] && (pwd = getpwuid_alloc(talloc_autofree_context(), geteuid()))) { fstrcpy(user_name, pwd->pw_name); TALLOC_FREE(pwd); } @@ -498,7 +498,7 @@ static int process_nonroot(int local_flags) } if (!user_name[0]) { - pwd = getpwuid_alloc(NULL, getuid()); + pwd = getpwuid_alloc(talloc_autofree_context(), getuid()); if (pwd) { fstrcpy(user_name,pwd->pw_name); TALLOC_FREE(pwd); |