diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-04-19 13:43:53 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-04-19 16:34:14 +1000 |
commit | e6cbbd9640e0e79653820e6cd5ea7b30c2e0f6bd (patch) | |
tree | ca2f289c30467ae3148bec40a8014bcc495166bd /source4/libnet | |
parent | 93f4f7a0375b95540d7f701c295b88ed9c6322d8 (diff) | |
download | samba-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
Diffstat (limited to 'source4/libnet')
-rw-r--r-- | source4/libnet/py_net.c | 15 |
1 files changed, 9 insertions, 6 deletions
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; } |