6729ff
From d790112e74b684a516152e301d5a46c178bf437c Mon Sep 17 00:00:00 2001
6729ff
From: Andreas Schneider <asn@samba.org>
6729ff
Date: Thu, 9 Jan 2014 14:50:18 +0100
6729ff
Subject: [PATCH 1/4] lib: Fix strict-aliasing warning in md5 code.
6729ff
MIME-Version: 1.0
6729ff
Content-Type: text/plain; charset=UTF-8
6729ff
Content-Transfer-Encoding: 8bit
6729ff
6729ff
If the compiler detects strict aliasing problems it isn't able to
6729ff
optimize the code.
6729ff
6729ff
Signed-off-by: Andreas Schneider <asn@samba.org>
6729ff
Reviewed-by: G端nther Deschner <gd@samba.org>
6729ff
(cherry picked from commit 615efa4ae84373ae8aefb36fcf7583338665429a)
6729ff
---
6729ff
 lib/crypto/md5.c | 9 ++++++---
6729ff
 1 file changed, 6 insertions(+), 3 deletions(-)
6729ff
6729ff
diff --git a/lib/crypto/md5.c b/lib/crypto/md5.c
6729ff
index b834c91..352f80f 100644
6729ff
--- a/lib/crypto/md5.c
6729ff
+++ b/lib/crypto/md5.c
6729ff
@@ -137,9 +137,12 @@ _PUBLIC_ void MD5Final(uint8_t digest[16], MD5_CTX *ctx)
6729ff
     }
6729ff
     byteReverse(ctx->in, 14);
6729ff
 
6729ff
-    /* Append length in bits and transform */
6729ff
-    ((uint32_t *) ctx->in)[14] = ctx->bits[0];
6729ff
-    ((uint32_t *) ctx->in)[15] = ctx->bits[1];
6729ff
+    /* Append length in bits and transform.
6729ff
+     * Use memcpy to avoid strict-aliasing problems.
6729ff
+     * This way it can be optimized.
6729ff
+     */
6729ff
+    memcpy(&ctx->in[14 * sizeof(uint32_t)], &ctx->bits[0], sizeof(uint32_t));
6729ff
+    memcpy(&ctx->in[15 * sizeof(uint32_t)], &ctx->bits[1], sizeof(uint32_t));
6729ff
 
6729ff
     MD5Transform(ctx->buf, (uint32_t *) ctx->in);
6729ff
     byteReverse((uint8_t *) ctx->buf, 4);
6729ff
-- 
6729ff
1.8.5.2
6729ff
6729ff
6729ff
From 38bae403ce6a8efaee5704328b47ec5b8300b5ed Mon Sep 17 00:00:00 2001
6729ff
From: Andreas Schneider <asn@samba.org>
6729ff
Date: Thu, 9 Jan 2014 15:06:14 +0100
6729ff
Subject: [PATCH 2/4] s3-libads: Fix memory leaks in ads_build_path().
6729ff
MIME-Version: 1.0
6729ff
Content-Type: text/plain; charset=UTF-8
6729ff
Content-Transfer-Encoding: 8bit
6729ff
6729ff
Signed-off-by: Andreas Schneider <asn@samba.org>
6729ff
Reviewed-by: G端nther Deschner <gd@samba.org>
6729ff
(cherry picked from commit c8371b4ec12f2dea6ce18724de59a23e04826c1d)
6729ff
---
6729ff
 source3/libads/ads_struct.c | 2 ++
6729ff
 1 file changed, 2 insertions(+)
6729ff
6729ff
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c
6729ff
index fd7e417..30d433e 100644
6729ff
--- a/source3/libads/ads_struct.c
6729ff
+++ b/source3/libads/ads_struct.c
6729ff
@@ -55,12 +55,14 @@ char *ads_build_path(const char *realm, const char *sep, const char *field, int
6729ff
 	if (strlcpy(ret,field, len) >= len) {
6729ff
 		/* Truncate ! */
6729ff
 		free(r);
6729ff
+		free(ret);
6729ff
 		return NULL;
6729ff
 	}
6729ff
 	p=strtok_r(r, sep, &saveptr);
6729ff
 	if (p) {
6729ff
 		if (strlcat(ret, p, len) >= len) {
6729ff
 			free(r);
6729ff
+			free(ret);
6729ff
 			return NULL;
6729ff
 		}
6729ff
 
6729ff
-- 
6729ff
1.8.5.2
6729ff
6729ff
6729ff
From 37eb6566dd18958cbe2f216aa9880e9455939426 Mon Sep 17 00:00:00 2001
6729ff
From: Andreas Schneider <asn@samba.org>
6729ff
Date: Thu, 9 Jan 2014 15:12:24 +0100
6729ff
Subject: [PATCH 3/4] wbinfo: Fix a memory leak in wbinfo_ping_dc().
6729ff
MIME-Version: 1.0
6729ff
Content-Type: text/plain; charset=UTF-8
6729ff
Content-Transfer-Encoding: 8bit
6729ff
6729ff
Signed-off-by: Andreas Schneider <asn@samba.org>
6729ff
Reviewed-by: G端nther Deschner <gd@samba.org>
6729ff
(cherry picked from commit 541164d47a86bab90ef96a9be40b8c0997abdd61)
6729ff
---
6729ff
 nsswitch/wbinfo.c | 1 +
6729ff
 1 file changed, 1 insertion(+)
6729ff
6729ff
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c
6729ff
index 3f0310a..0a5ec40 100644
6729ff
--- a/nsswitch/wbinfo.c
6729ff
+++ b/nsswitch/wbinfo.c
6729ff
@@ -838,6 +838,7 @@ static bool wbinfo_ping_dc(void)
6729ff
 		 dcname ? dcname : "",
6729ff
 		 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
6729ff
 
6729ff
+	wbcFreeMemory(dcname);
6729ff
 	if (wbc_status == WBC_ERR_AUTH_ERROR) {
6729ff
 		d_fprintf(stderr, "error code was %s (0x%x)\n",
6729ff
 			  error->nt_string, error->nt_status);
6729ff
-- 
6729ff
1.8.5.2
6729ff
6729ff
6729ff
From f203bfbd91a695f582a6c7ea2fae2c8f3c6825c9 Mon Sep 17 00:00:00 2001
6729ff
From: Andreas Schneider <asn@samba.org>
6729ff
Date: Thu, 9 Jan 2014 15:20:21 +0100
6729ff
Subject: [PATCH 4/4] s3-passdb: Fix string duplication to pointers.
6729ff
MIME-Version: 1.0
6729ff
Content-Type: text/plain; charset=UTF-8
6729ff
Content-Transfer-Encoding: 8bit
6729ff
6729ff
Signed-off-by: Andreas Schneider <asn@samba.org>
6729ff
Reviewed-by: G端nther Deschner <gd@samba.org>
6729ff
6729ff
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
6729ff
Autobuild-Date(master): Thu Jan  9 22:35:25 CET 2014 on sn-devel-104
6729ff
6729ff
(cherry picked from commit bff3ac250e9d4e7d91820eb53c28257aa38fff88)
6729ff
---
6729ff
 source3/passdb/py_passdb.c | 14 ++++++++++++--
6729ff
 1 file changed, 12 insertions(+), 2 deletions(-)
6729ff
6729ff
diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c
6729ff
index 3fd14cd..e1df75b 100644
6729ff
--- a/source3/passdb/py_passdb.c
6729ff
+++ b/source3/passdb/py_passdb.c
6729ff
@@ -2269,8 +2269,18 @@ static PyObject *py_pdb_set_aliasinfo(pytalloc_Object *self, PyObject *args)
6729ff
 
6729ff
 	alias_sid = pytalloc_get_ptr(py_alias_sid);
6729ff
 
6729ff
-	fstrcpy(alias_info.acct_name, PyString_AsString(PyDict_GetItemString(py_alias_info, "acct_name")));
6729ff
-	fstrcpy(alias_info.acct_desc, PyString_AsString(PyDict_GetItemString(py_alias_info, "acct_desc")));
6729ff
+	alias_info.acct_name = talloc_strdup(frame, PyString_AsString(PyDict_GetItemString(py_alias_info, "acct_name")));
6729ff
+	if (alias_info.acct_name == NULL) {
6729ff
+		PyErr_Format(py_pdb_error, "Unable to allocate memory");
6729ff
+		talloc_free(frame);
6729ff
+		return NULL;
6729ff
+	}
6729ff
+	alias_info.acct_desc = talloc_strdup(frame, PyString_AsString(PyDict_GetItemString(py_alias_info, "acct_desc")));
6729ff
+	if (alias_info.acct_desc == NULL) {
6729ff
+		PyErr_Format(py_pdb_error, "Unable to allocate memory");
6729ff
+		talloc_free(frame);
6729ff
+		return NULL;
6729ff
+	}
6729ff
 
6729ff
 	status = methods->set_aliasinfo(methods, alias_sid, &alias_info);
6729ff
 	if (!NT_STATUS_IS_OK(status)) {
6729ff
-- 
6729ff
1.8.5.2
6729ff