svn commit: samba r18971 - in branches/SAMBA_4_0/source:
lib/registry/common libcli/auth torture/rpc
tridge at samba.org
tridge at samba.org
Thu Sep 28 06:44:48 GMT 2006
Author: tridge
Date: 2006-09-28 06:44:47 +0000 (Thu, 28 Sep 2006)
New Revision: 18971
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18971
Log:
avoid strndup is a few places. Fixes a minor memory leak, and should
fix RPC-LSA on AIX.
Modified:
branches/SAMBA_4_0/source/lib/registry/common/reg_util.c
branches/SAMBA_4_0/source/libcli/auth/session.c
branches/SAMBA_4_0/source/torture/rpc/lsa.c
branches/SAMBA_4_0/source/torture/rpc/session_key.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/registry/common/reg_util.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/common/reg_util.c 2006-09-28 06:43:27 UTC (rev 18970)
+++ branches/SAMBA_4_0/source/lib/registry/common/reg_util.c 2006-09-28 06:44:47 UTC (rev 18971)
@@ -171,9 +171,9 @@
if(strchr(name, '\\')) predeflength = strchr(name, '\\')-name;
else predeflength = strlen(name);
- predefname = strndup(name, predeflength);
+ predefname = talloc_strndup(mem_ctx, name, predeflength);
error = reg_get_predefined_key_by_name(handle, predefname, &predef);
- SAFE_FREE(predefname);
+ talloc_free(predefname);
if(!W_ERROR_IS_OK(error)) {
return error;
Modified: branches/SAMBA_4_0/source/libcli/auth/session.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/auth/session.c 2006-09-28 06:43:27 UTC (rev 18970)
+++ branches/SAMBA_4_0/source/libcli/auth/session.c 2006-09-28 06:44:47 UTC (rev 18971)
@@ -97,7 +97,8 @@
caller should free the returned string
*/
-char *sess_decrypt_string(DATA_BLOB *blob, const DATA_BLOB *session_key)
+char *sess_decrypt_string(TALLOC_CTX *mem_ctx,
+ DATA_BLOB *blob, const DATA_BLOB *session_key)
{
DATA_BLOB out;
int slen;
@@ -107,7 +108,7 @@
return NULL;
}
- out = data_blob(NULL, blob->length);
+ out = data_blob_talloc(mem_ctx, NULL, blob->length);
if (!out.data) {
return NULL;
}
@@ -117,19 +118,23 @@
if (IVAL(out.data, 4) != 1) {
DEBUG(0,("Unexpected revision number %d in session crypted string\n",
IVAL(out.data, 4)));
+ data_blob_free(&out);
return NULL;
}
slen = IVAL(out.data, 0);
if (slen > blob->length - 8) {
DEBUG(0,("Invalid crypt length %d\n", slen));
+ data_blob_free(&out);
return NULL;
}
- ret = strndup((const char *)(out.data+8), slen);
+ ret = talloc_strndup(mem_ctx, (const char *)(out.data+8), slen);
data_blob_free(&out);
+ DEBUG(0,("decrypted string '%s' of length %d\n", ret, slen));
+
return ret;
}
Modified: branches/SAMBA_4_0/source/torture/rpc/lsa.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/lsa.c 2006-09-28 06:43:27 UTC (rev 18970)
+++ branches/SAMBA_4_0/source/torture/rpc/lsa.c 2006-09-28 06:44:47 UTC (rev 18971)
@@ -976,7 +976,8 @@
blob2 = data_blob_talloc(mem_ctx, NULL, blob1.length);
- secret2 = sess_decrypt_string(&blob1, &session_key);
+ secret2 = sess_decrypt_string(mem_ctx,
+ &blob1, &session_key);
if (strcmp(secret1, secret2) != 0) {
printf("Returned secret '%s' doesn't match '%s'\n",
@@ -1036,7 +1037,8 @@
blob2 = data_blob_talloc(mem_ctx, NULL, blob1.length);
- secret4 = sess_decrypt_string(&blob1, &session_key);
+ secret4 = sess_decrypt_string(mem_ctx,
+ &blob1, &session_key);
if (strcmp(secret3, secret4) != 0) {
printf("Returned NEW secret %s doesn't match %s\n", secret4, secret3);
@@ -1048,7 +1050,8 @@
blob2 = data_blob_talloc(mem_ctx, NULL, blob1.length);
- secret2 = sess_decrypt_string(&blob1, &session_key);
+ secret2 = sess_decrypt_string(mem_ctx,
+ &blob1, &session_key);
if (strcmp(secret1, secret2) != 0) {
printf("Returned OLD secret %s doesn't match %s\n", secret2, secret1);
@@ -1122,7 +1125,8 @@
blob2 = data_blob_talloc(mem_ctx, NULL, blob1.length);
- secret6 = sess_decrypt_string(&blob1, &session_key);
+ secret6 = sess_decrypt_string(mem_ctx,
+ &blob1, &session_key);
if (strcmp(secret3, secret4) != 0) {
printf("Returned NEW secret '%s' doesn't match '%s'\n", secret4, secret3);
@@ -1134,7 +1138,8 @@
blob2 = data_blob_talloc(mem_ctx, NULL, blob1.length);
- secret6 = sess_decrypt_string(&blob1, &session_key);
+ secret6 = sess_decrypt_string(mem_ctx,
+ &blob1, &session_key);
if (strcmp(secret5, secret6) != 0) {
printf("Returned OLD secret %s doesn't match %s\n", secret5, secret6);
Modified: branches/SAMBA_4_0/source/torture/rpc/session_key.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/session_key.c 2006-09-28 06:43:27 UTC (rev 18970)
+++ branches/SAMBA_4_0/source/torture/rpc/session_key.c 2006-09-28 06:44:47 UTC (rev 18971)
@@ -139,7 +139,7 @@
blob2 = data_blob_talloc(mem_ctx, NULL, blob1.length);
- secret2 = sess_decrypt_string(&blob1, &session_key);
+ secret2 = sess_decrypt_string(mem_ctx, &blob1, &session_key);
if (strcmp(secret1, secret2) != 0) {
printf("Returned secret '%s' doesn't match '%s'\n",
More information about the samba-cvs
mailing list