svn commit: samba r13256 - in branches/SAMBA_4_0/source:
dsdb/samdb/ldb_modules lib
abartlet at samba.org
abartlet at samba.org
Tue Jan 31 10:03:46 GMT 2006
Author: abartlet
Date: 2006-01-31 10:03:44 +0000 (Tue, 31 Jan 2006)
New Revision: 13256
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13256
Log:
Free temporary memory on error cases, and try to clean up what's left
earlier.
Move gendb_search() to use talloc_vasprintf() and steal only the parts
actually being used for the results.
Andrew Bartlett
Modified:
branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/password_hash.c
branches/SAMBA_4_0/source/lib/gendb.c
Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/password_hash.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/password_hash.c 2006-01-31 06:09:18 UTC (rev 13255)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/password_hash.c 2006-01-31 10:03:44 UTC (rev 13256)
@@ -157,6 +157,7 @@
/* look again, this time at the copied attribute */
if (!msg2 || (attribute = ldb_msg_find_element(msg2, "sambaPassword")) == NULL ) {
+ talloc_free(mem_ctx);
/* Gah? where did it go? Oh well... */
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -170,6 +171,7 @@
talloc_asprintf(mem_ctx, "sambaPassword_handle: "
"attempted set of multiple sambaPassword attributes on %s rejected",
ldb_dn_linearize(mem_ctx, dn)));
+ talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -184,6 +186,7 @@
talloc_asprintf(mem_ctx, "sambaPassword_handle: "
"attempted set of multiple sambaPassword attributes on %s rejected",
ldb_dn_linearize(mem_ctx, dn)));
+ talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -212,6 +215,7 @@
/* Send the (modified) request of the original caller down to the database */
ret = ldb_next_request(module, modified_orig_request);
if (ret) {
+ talloc_free(mem_ctx);
return ret;
}
@@ -226,6 +230,8 @@
/* Find out the old passwords details of the user */
old_res = search_request->op.search.res;
+ talloc_steal(mem_ctx, old_res);
+ talloc_free(search_request);
if (old_res->count != 1) {
ldb_set_errstring(module,
@@ -270,6 +276,9 @@
/* Find out the full details of the user */
res = search_request->op.search.res;
+ talloc_steal(mem_ctx, res);
+ talloc_free(search_request);
+
if (res->count != 1) {
ldb_set_errstring(module,
talloc_asprintf(mem_ctx, "password_hash_handle: "
Modified: branches/SAMBA_4_0/source/lib/gendb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/gendb.c 2006-01-31 06:09:18 UTC (rev 13255)
+++ branches/SAMBA_4_0/source/lib/gendb.c 2006-01-31 10:03:44 UTC (rev 13256)
@@ -42,7 +42,7 @@
int ret;
if (format) {
- vasprintf(&expr, format, ap);
+ expr = talloc_vasprintf(mem_ctx, format, ap);
if (expr == NULL) {
return -1;
}
@@ -55,7 +55,7 @@
ret = ldb_search(ldb, basedn, scope, expr, attrs, &res);
if (ret == LDB_SUCCESS) {
- talloc_steal(mem_ctx, res);
+ talloc_steal(mem_ctx, res->msgs);
DEBUG(4,("gendb_search_v: %s %s -> %d\n",
basedn?ldb_dn_linearize(mem_ctx,basedn):"NULL",
@@ -63,13 +63,13 @@
ret = res->count;
*msgs = res->msgs;
-
+ talloc_free(res);
} else {
DEBUG(4,("gendb_search_v: search failed: %s", ldb_errstring(ldb)));
ret = -1;
}
- free(expr);
+ talloc_free(expr);
return ret;
}
More information about the samba-cvs
mailing list