summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-11-06 20:48:13 -0800
committerJeremy Allison <jra@samba.org>2008-11-06 20:48:13 -0800
commit8962be69c700224983af4effd2cd086f7f5800b0 (patch)
treead2149c31ca5102a213a13a75cd511b11c64d812 /source3/utils
parent7ae625345536572aa946f0715542a5cf2dbc2169 (diff)
downloadsamba-8962be69c700224983af4effd2cd086f7f5800b0.tar.gz
samba-8962be69c700224983af4effd2cd086f7f5800b0.tar.bz2
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.c2
-rw-r--r--source3/utils/pdbedit.c4
-rw-r--r--source3/utils/smbpasswd.c4
3 files changed, 5 insertions, 5 deletions
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c
index ce132131f7..e8ebb60205 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 fe99b6fc9e..50cbc43d6d 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 600fe52f0d..d2652ad95a 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);