[PATCH 4/4] s3-passdb: Fix string duplication to pointers.

Andreas Schneider asn at samba.org
Thu Jan 9 07:23:43 MST 2014


Signed-off-by: Andreas Schneider <asn at samba.org>
---
 source3/passdb/py_passdb.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c
index 3fd14cd..e1df75b 100644
--- a/source3/passdb/py_passdb.c
+++ b/source3/passdb/py_passdb.c
@@ -2269,8 +2269,18 @@ static PyObject *py_pdb_set_aliasinfo(pytalloc_Object *self, PyObject *args)
 
 	alias_sid = pytalloc_get_ptr(py_alias_sid);
 
-	fstrcpy(alias_info.acct_name, PyString_AsString(PyDict_GetItemString(py_alias_info, "acct_name")));
-	fstrcpy(alias_info.acct_desc, PyString_AsString(PyDict_GetItemString(py_alias_info, "acct_desc")));
+	alias_info.acct_name = talloc_strdup(frame, PyString_AsString(PyDict_GetItemString(py_alias_info, "acct_name")));
+	if (alias_info.acct_name == NULL) {
+		PyErr_Format(py_pdb_error, "Unable to allocate memory");
+		talloc_free(frame);
+		return NULL;
+	}
+	alias_info.acct_desc = talloc_strdup(frame, PyString_AsString(PyDict_GetItemString(py_alias_info, "acct_desc")));
+	if (alias_info.acct_desc == NULL) {
+		PyErr_Format(py_pdb_error, "Unable to allocate memory");
+		talloc_free(frame);
+		return NULL;
+	}
 
 	status = methods->set_aliasinfo(methods, alias_sid, &alias_info);
 	if (!NT_STATUS_IS_OK(status)) {
-- 
1.8.5.2




More information about the samba-technical mailing list