diff options
author | Volker Lendecke <vlendec@samba.org> | 2003-06-18 12:00:52 +0000 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2003-06-18 12:00:52 +0000 |
commit | e6fd597fce61787789b76c323c56edc979e4e1fc (patch) | |
tree | e4fa003a56b1067a700e8f15e277df78f9eb42ad /source3 | |
parent | e48ebd09ffc57633fcb96c3a9406c9e7f65c5b3c (diff) | |
download | samba-e6fd597fce61787789b76c323c56edc979e4e1fc.tar.gz samba-e6fd597fce61787789b76c323c56edc979e4e1fc.tar.bz2 samba-e6fd597fce61787789b76c323c56edc979e4e1fc.zip |
And some more memory leaks in mapping.c and pdb_tdb.c. tdb_nextkey
mallocs its key, so we should free it after use.
Volker
(This used to be commit 9750799ba2e1aaa59fa255f23880c9c618195c3d)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/groupdb/mapping.c | 2 | ||||
-rw-r--r-- | source3/passdb/pdb_tdb.c | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c index 5b5d0b0cc3..e13730b141 100644 --- a/source3/groupdb/mapping.c +++ b/source3/groupdb/mapping.c @@ -625,6 +625,7 @@ static BOOL get_group_map_from_gid(gid_t gid, GROUP_MAP *map, BOOL with_priv) if (gid==map->gid) { if (!with_priv) free_privilege(&map->priv_set); + SAFE_FREE(kbuf.dptr); return True; } @@ -692,6 +693,7 @@ static BOOL get_group_map_from_ntname(char *name, GROUP_MAP *map, BOOL with_priv if (StrCaseCmp(name, map->nt_name)==0) { if (!with_priv) free_privilege(&map->priv_set); + SAFE_FREE(kbuf.dptr); return True; } diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index d323c20d32..2cf7a0119f 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -490,6 +490,7 @@ static void close_tdb(struct tdbsam_privates *tdb_state) static void tdbsam_endsampwent(struct pdb_methods *my_methods) { struct tdbsam_privates *tdb_state = (struct tdbsam_privates *)my_methods->private_data; + SAFE_FREE(tdb_state->key.dptr); close_tdb(tdb_state); DEBUG(7, ("endtdbpwent: closed sam database.\n")); @@ -503,7 +504,7 @@ static NTSTATUS tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT * { NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; struct tdbsam_privates *tdb_state = (struct tdbsam_privates *)my_methods->private_data; - TDB_DATA data; + TDB_DATA data, old_key; const char *prefix = USERPREFIX; int prefixlen = strlen (prefix); @@ -514,10 +515,16 @@ static NTSTATUS tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT * } /* skip all non-USER entries (eg. RIDs) */ - while ((tdb_state->key.dsize != 0) && (strncmp(tdb_state->key.dptr, prefix, prefixlen))) + while ((tdb_state->key.dsize != 0) && (strncmp(tdb_state->key.dptr, prefix, prefixlen))) { + + old_key = tdb_state->key; + /* increment to next in line */ tdb_state->key = tdb_nextkey(tdb_state->passwd_tdb, tdb_state->key); + SAFE_FREE(old_key.dptr); + } + /* do we have an valid iteration pointer? */ if(tdb_state->passwd_tdb == NULL) { DEBUG(0,("pdb_get_sampwent: Bad TDB Context pointer.\n")); @@ -538,9 +545,13 @@ static NTSTATUS tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT * } SAFE_FREE(data.dptr); + old_key = tdb_state->key; + /* increment to next in line */ tdb_state->key = tdb_nextkey(tdb_state->passwd_tdb, tdb_state->key); + SAFE_FREE(old_key.dptr); + return NT_STATUS_OK; } |