svn commit: samba r10213 - in branches/SAMBA_4_0/source:
ldap_server libcli/cldap libcli/ldap
tridge at samba.org
tridge at samba.org
Tue Sep 13 22:05:46 GMT 2005
Author: tridge
Date: 2005-09-13 22:05:45 +0000 (Tue, 13 Sep 2005)
New Revision: 10213
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10213
Log:
fixed a memory leak in the ldap client and server code spotted by Karl
Melcher. ldap_encode() now takes a memory context to use for the data
blob
Modified:
branches/SAMBA_4_0/source/ldap_server/ldap_server.c
branches/SAMBA_4_0/source/libcli/cldap/cldap.c
branches/SAMBA_4_0/source/libcli/ldap/ldap.c
branches/SAMBA_4_0/source/libcli/ldap/ldap_client.c
Changeset:
Modified: branches/SAMBA_4_0/source/ldap_server/ldap_server.c
===================================================================
--- branches/SAMBA_4_0/source/ldap_server/ldap_server.c 2005-09-13 21:31:40 UTC (rev 10212)
+++ branches/SAMBA_4_0/source/ldap_server/ldap_server.c 2005-09-13 22:05:45 UTC (rev 10213)
@@ -87,12 +87,14 @@
DATA_BLOB b;
msg = call->replies->msg;
- if (!ldap_encode(msg, &b)) {
+ if (!ldap_encode(msg, &b, call)) {
DEBUG(0,("Failed to encode ldap reply of type %d\n", msg->type));
goto failed;
}
status = data_blob_append(call, &blob, b.data, b.length);
+ data_blob_free(&b);
+
if (!NT_STATUS_IS_OK(status)) goto failed;
DLIST_REMOVE(call->replies, call->replies);
Modified: branches/SAMBA_4_0/source/libcli/cldap/cldap.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/cldap/cldap.c 2005-09-13 21:31:40 UTC (rev 10212)
+++ branches/SAMBA_4_0/source/libcli/cldap/cldap.c 2005-09-13 22:05:45 UTC (rev 10213)
@@ -337,12 +337,11 @@
goto failed;
}
- if (!ldap_encode(msg, &req->encoded)) {
+ if (!ldap_encode(msg, &req->encoded, req)) {
DEBUG(0,("Failed to encode cldap message to %s:%d\n",
req->dest_addr, req->dest_port));
goto failed;
}
- talloc_steal(req, req->encoded.data);
DLIST_ADD_END(cldap->send_queue, req, struct cldap_request *);
@@ -389,13 +388,12 @@
msg->type = LDAP_TAG_SearchResultEntry;
msg->r.SearchResultEntry = *io->response;
- if (!ldap_encode(msg, &blob1)) {
+ if (!ldap_encode(msg, &blob1, req)) {
DEBUG(0,("Failed to encode cldap message to %s:%d\n",
req->dest_addr, req->dest_port));
status = NT_STATUS_INVALID_PARAMETER;
goto failed;
}
- talloc_steal(req, blob1.data);
} else {
blob1 = data_blob(NULL, 0);
}
@@ -403,13 +401,12 @@
msg->type = LDAP_TAG_SearchResultDone;
msg->r.SearchResultDone = *io->result;
- if (!ldap_encode(msg, &blob2)) {
+ if (!ldap_encode(msg, &blob2, req)) {
DEBUG(0,("Failed to encode cldap message to %s:%d\n",
req->dest_addr, req->dest_port));
status = NT_STATUS_INVALID_PARAMETER;
goto failed;
}
- talloc_steal(req, blob2.data);
req->encoded = data_blob_talloc(req, NULL, blob1.length + blob2.length);
if (req->encoded.data == NULL) goto failed;
Modified: branches/SAMBA_4_0/source/libcli/ldap/ldap.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/ldap/ldap.c 2005-09-13 21:31:40 UTC (rev 10212)
+++ branches/SAMBA_4_0/source/libcli/ldap/ldap.c 2005-09-13 22:05:45 UTC (rev 10213)
@@ -189,7 +189,7 @@
}
}
-BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result)
+BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ctx)
{
struct asn1_data data;
int i, j;
@@ -462,7 +462,7 @@
return False;
}
- *result = data_blob(data.data, data.length);
+ *result = data_blob_talloc(mem_ctx, data.data, data.length);
asn1_free(&data);
return True;
}
Modified: branches/SAMBA_4_0/source/libcli/ldap/ldap_client.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/ldap/ldap_client.c 2005-09-13 21:31:40 UTC (rev 10212)
+++ branches/SAMBA_4_0/source/libcli/ldap/ldap_client.c 2005-09-13 22:05:45 UTC (rev 10213)
@@ -497,7 +497,7 @@
msg->messageid = req->messageid;
- if (!ldap_encode(msg, &req->data)) {
+ if (!ldap_encode(msg, &req->data, req)) {
goto failed;
}
More information about the samba-cvs
mailing list