summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-04-19 13:43:53 +1000
committerAndrew Tridgell <tridge@samba.org>2010-04-19 16:34:14 +1000
commite6cbbd9640e0e79653820e6cd5ea7b30c2e0f6bd (patch)
treeca2f289c30467ae3148bec40a8014bcc495166bd
parent93f4f7a0375b95540d7f701c295b88ed9c6322d8 (diff)
downloadsamba-e6cbbd9640e0e79653820e6cd5ea7b30c2e0f6bd.tar.gz
samba-e6cbbd9640e0e79653820e6cd5ea7b30c2e0f6bd.tar.bz2
samba-e6cbbd9640e0e79653820e6cd5ea7b30c2e0f6bd.zip
s4-python: PyErr_SetString() will crash on NULL strings
use nt_errstr() when no error available
-rw-r--r--source4/auth/credentials/pycredentials.c2
-rw-r--r--source4/libnet/py_net.c15
2 files changed, 10 insertions, 7 deletions
diff --git a/source4/auth/credentials/pycredentials.c b/source4/auth/credentials/pycredentials.c
index c5cca4fb32..361e4c9a1f 100644
--- a/source4/auth/credentials/pycredentials.c
+++ b/source4/auth/credentials/pycredentials.c
@@ -283,7 +283,7 @@ static PyObject *py_creds_get_named_ccache(py_talloc_Object *self, PyObject *arg
return PyCredentialCacheContainer_from_ccache_container(ccc);
}
- PyErr_SetString(PyExc_RuntimeError, error_string);
+ PyErr_SetString(PyExc_RuntimeError, error_string?error_string:"NULL");
talloc_free(event_ctx);
return NULL;
diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c
index ec41ca38a8..6bd4c0ca84 100644
--- a/source4/libnet/py_net.c
+++ b/source4/libnet/py_net.c
@@ -52,7 +52,7 @@ static PyObject *py_net_join(py_net_Object *self, PyObject *args, PyObject *kwar
status = libnet_Join(self->libnet_ctx, mem_ctx, &r);
if (NT_STATUS_IS_ERR(status)) {
- PyErr_SetString(PyExc_RuntimeError, r.out.error_string);
+ PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status));
talloc_free(mem_ctx);
return NULL;
}
@@ -93,7 +93,8 @@ static PyObject *py_net_set_password(py_net_Object *self, PyObject *args, PyObje
status = libnet_SetPassword(self->libnet_ctx, mem_ctx, &r);
if (NT_STATUS_IS_ERR(status)) {
- PyErr_SetString(PyExc_RuntimeError, r.generic.out.error_string);
+ PyErr_SetString(PyExc_RuntimeError,
+ r.generic.out.error_string?r.generic.out.error_string:nt_errstr(status));
talloc_free(mem_ctx);
return NULL;
}
@@ -127,7 +128,8 @@ static PyObject *py_net_export_keytab(py_net_Object *self, PyObject *args, PyObj
status = libnet_export_keytab(self->libnet_ctx, mem_ctx, &r);
if (NT_STATUS_IS_ERR(status)) {
- PyErr_SetString(PyExc_RuntimeError, r.out.error_string);
+ PyErr_SetString(PyExc_RuntimeError,
+ r.out.error_string?r.out.error_string:nt_errstr(status));
talloc_free(mem_ctx);
return NULL;
}
@@ -164,7 +166,8 @@ static PyObject *py_net_time(py_net_Object *self, PyObject *args, PyObject *kwar
status = libnet_RemoteTOD(self->libnet_ctx, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- PyErr_SetString(PyExc_RuntimeError, r.generic.out.error_string);
+ PyErr_SetString(PyExc_RuntimeError,
+ r.generic.out.error_string?r.generic.out.error_string:nt_errstr(status));
talloc_free(mem_ctx);
return NULL;
}
@@ -204,7 +207,7 @@ static PyObject *py_net_user_create(py_net_Object *self, PyObject *args, PyObjec
status = libnet_CreateUser(self->libnet_ctx, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- PyErr_SetString(PyExc_RuntimeError, r.out.error_string);
+ PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status));
talloc_free(mem_ctx);
return NULL;
}
@@ -238,7 +241,7 @@ static PyObject *py_net_user_delete(py_net_Object *self, PyObject *args, PyObjec
status = libnet_DeleteUser(self->libnet_ctx, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- PyErr_SetString(PyExc_RuntimeError, r.out.error_string);
+ PyErr_SetString(PyExc_RuntimeError, r.out.error_string?r.out.error_string:nt_errstr(status));
talloc_free(mem_ctx);
return NULL;
}