diff options
Diffstat (limited to 'source4')
41 files changed, 430 insertions, 250 deletions
diff --git a/source4/Makefile b/source4/Makefile index 267e302c9f7..508836f6da0 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -146,7 +146,7 @@ endif clean:: @find ../lib ../libcli ../librpc ../nsswitch -name '*.o' -o -name '*.ho' | xargs rm -f -PUBLIC_HEADES += $(srcdir)/version.h +PUBLIC_HEADERS += $(srcdir)/version.h libraries:: $(STATIC_LIBS) $(SHARED_LIBS) modules:: $(PLUGINS) diff --git a/source4/auth/credentials/pycredentials.c b/source4/auth/credentials/pycredentials.c index 6fcab80ce66..3eacf9ada1f 100644 --- a/source4/auth/credentials/pycredentials.c +++ b/source4/auth/credentials/pycredentials.c @@ -34,8 +34,7 @@ struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj) if (py_obj == Py_None) { return cli_credentials_init_anon(NULL); } - - /* FIXME: Check type? */ + return PyCredentials_AsCliCredentials(py_obj); } @@ -53,7 +52,7 @@ static PyObject *py_creds_new(PyTypeObject *type, PyObject *args, PyObject *kwar static PyObject *py_creds_get_username(py_talloc_Object *self) { - return PyString_FromStringOrNULL(cli_credentials_get_username(self->ptr)); + return PyString_FromStringOrNULL(cli_credentials_get_username(PyCredentials_AsCliCredentials(self))); } static PyObject *py_creds_set_username(py_talloc_Object *self, PyObject *args) @@ -63,12 +62,12 @@ static PyObject *py_creds_set_username(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s|i", &newval, &obt)) return NULL; - return PyBool_FromLong(cli_credentials_set_username(self->ptr, newval, obt)); + return PyBool_FromLong(cli_credentials_set_username(PyCredentials_AsCliCredentials(self), newval, obt)); } static PyObject *py_creds_get_password(py_talloc_Object *self) { - return PyString_FromStringOrNULL(cli_credentials_get_password(self->ptr)); + return PyString_FromStringOrNULL(cli_credentials_get_password(PyCredentials_AsCliCredentials(self))); } @@ -79,12 +78,12 @@ static PyObject *py_creds_set_password(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s|i", &newval, &obt)) return NULL; - return PyBool_FromLong(cli_credentials_set_password(self->ptr, newval, obt)); + return PyBool_FromLong(cli_credentials_set_password(PyCredentials_AsCliCredentials(self), newval, obt)); } static PyObject *py_creds_get_domain(py_talloc_Object *self) { - return PyString_FromStringOrNULL(cli_credentials_get_domain(self->ptr)); + return PyString_FromStringOrNULL(cli_credentials_get_domain(PyCredentials_AsCliCredentials(self))); } static PyObject *py_creds_set_domain(py_talloc_Object *self, PyObject *args) @@ -94,12 +93,12 @@ static PyObject *py_creds_set_domain(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s|i", &newval, &obt)) return NULL; - return PyBool_FromLong(cli_credentials_set_domain(self->ptr, newval, obt)); + return PyBool_FromLong(cli_credentials_set_domain(PyCredentials_AsCliCredentials(self), newval, obt)); } static PyObject *py_creds_get_realm(py_talloc_Object *self) { - return PyString_FromStringOrNULL(cli_credentials_get_realm(self->ptr)); + return PyString_FromStringOrNULL(cli_credentials_get_realm(PyCredentials_AsCliCredentials(self))); } static PyObject *py_creds_set_realm(py_talloc_Object *self, PyObject *args) @@ -109,12 +108,12 @@ static PyObject *py_creds_set_realm(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s|i", &newval, &obt)) return NULL; - return PyBool_FromLong(cli_credentials_set_realm(self->ptr, newval, obt)); + return PyBool_FromLong(cli_credentials_set_realm(PyCredentials_AsCliCredentials(self), newval, obt)); } static PyObject *py_creds_get_bind_dn(py_talloc_Object *self) { - return PyString_FromStringOrNULL(cli_credentials_get_bind_dn(self->ptr)); + return PyString_FromStringOrNULL(cli_credentials_get_bind_dn(PyCredentials_AsCliCredentials(self))); } static PyObject *py_creds_set_bind_dn(py_talloc_Object *self, PyObject *args) @@ -123,12 +122,12 @@ static PyObject *py_creds_set_bind_dn(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s", &newval)) return NULL; - return PyBool_FromLong(cli_credentials_set_bind_dn(self->ptr, newval)); + return PyBool_FromLong(cli_credentials_set_bind_dn(PyCredentials_AsCliCredentials(self), newval)); } static PyObject *py_creds_get_workstation(py_talloc_Object *self) { - return PyString_FromStringOrNULL(cli_credentials_get_workstation(self->ptr)); + return PyString_FromStringOrNULL(cli_credentials_get_workstation(PyCredentials_AsCliCredentials(self))); } static PyObject *py_creds_set_workstation(py_talloc_Object *self, PyObject *args) @@ -138,33 +137,33 @@ static PyObject *py_creds_set_workstation(py_talloc_Object *self, PyObject *args if (!PyArg_ParseTuple(args, "s|i", &newval, &obt)) return NULL; - return PyBool_FromLong(cli_credentials_set_workstation(self->ptr, newval, obt)); + return PyBool_FromLong(cli_credentials_set_workstation(PyCredentials_AsCliCredentials(self), newval, obt)); } static PyObject *py_creds_is_anonymous(py_talloc_Object *self) { - return PyBool_FromLong(cli_credentials_is_anonymous(self->ptr)); + return PyBool_FromLong(cli_credentials_is_anonymous(PyCredentials_AsCliCredentials(self))); } static PyObject *py_creds_set_anonymous(py_talloc_Object *self) { - cli_credentials_set_anonymous(self->ptr); + cli_credentials_set_anonymous(PyCredentials_AsCliCredentials(self)); Py_RETURN_NONE; } static PyObject *py_creds_authentication_requested(py_talloc_Object *self) { - return PyBool_FromLong(cli_credentials_authentication_requested(self->ptr)); + return PyBool_FromLong(cli_credentials_authentication_requested(PyCredentials_AsCliCredentials(self))); } static PyObject *py_creds_wrong_password(py_talloc_Object *self) { - return PyBool_FromLong(cli_credentials_wrong_password(self->ptr)); + return PyBool_FromLong(cli_credentials_wrong_password(PyCredentials_AsCliCredentials(self))); } static PyObject *py_creds_set_cmdline_callbacks(py_talloc_Object *self) { - return PyBool_FromLong(cli_credentials_set_cmdline_callbacks(self->ptr)); + return PyBool_FromLong(cli_credentials_set_cmdline_callbacks(PyCredentials_AsCliCredentials(self))); } static PyObject *py_creds_parse_string(py_talloc_Object *self, PyObject *args) @@ -174,15 +173,15 @@ static PyObject *py_creds_parse_string(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s|i", &newval, &obt)) return NULL; - cli_credentials_parse_string(self->ptr, newval, obt); + cli_credentials_parse_string(PyCredentials_AsCliCredentials(self), newval, obt); Py_RETURN_NONE; } static PyObject *py_creds_get_nt_hash(py_talloc_Object *self) { - const struct samr_Password *ntpw = cli_credentials_get_nt_hash(self->ptr, self->ptr); + const struct samr_Password *ntpw = cli_credentials_get_nt_hash(PyCredentials_AsCliCredentials(self), self->ptr); - return PyString_FromStringAndSize((char *)ntpw->hash, 16); + return PyString_FromStringAndSize(discard_const_p(char, ntpw->hash), 16); } static PyObject *py_creds_set_kerberos_state(py_talloc_Object *self, PyObject *args) @@ -191,7 +190,7 @@ static PyObject *py_creds_set_kerberos_state(py_talloc_Object *self, PyObject *a if (!PyArg_ParseTuple(args, "i", &state)) return NULL; - cli_credentials_set_kerberos_state(self->ptr, state); + cli_credentials_set_kerberos_state(PyCredentials_AsCliCredentials(self), state); Py_RETURN_NONE; } @@ -206,7 +205,7 @@ static PyObject *py_creds_guess(py_talloc_Object *self, PyObject *args) if (lp_ctx == NULL) return NULL; - cli_credentials_guess(self->ptr, lp_ctx); + cli_credentials_guess(PyCredentials_AsCliCredentials(self), lp_ctx); Py_RETURN_NONE; } @@ -223,7 +222,7 @@ static PyObject *py_creds_set_machine_account(py_talloc_Object *self, PyObject * if (lp_ctx == NULL) return NULL; - status = cli_credentials_set_machine_account(self->ptr, lp_ctx); + status = cli_credentials_set_machine_account(PyCredentials_AsCliCredentials(self), lp_ctx); PyErr_NTSTATUS_IS_ERR_RAISE(status); Py_RETURN_NONE; diff --git a/source4/auth/credentials/pycredentials.h b/source4/auth/credentials/pycredentials.h index 44241277759..f2e15fad61d 100644 --- a/source4/auth/credentials/pycredentials.h +++ b/source4/auth/credentials/pycredentials.h @@ -25,6 +25,6 @@ PyAPI_DATA(PyTypeObject) PyCredentials; struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj); #define PyCredentials_Check(py_obj) PyObject_TypeCheck(py_obj, &PyCredentials) -#define PyCredentials_AsCliCredentials(py_obj) py_talloc_get_ptr(py_obj) +#define PyCredentials_AsCliCredentials(py_obj) py_talloc_get_type(py_obj, struct cli_credentials) #endif /* _PYCREDENTIALS_H_ */ diff --git a/source4/auth/ntlm/auth.c b/source4/auth/ntlm/auth.c index d00c81206af..20967a6bda3 100644 --- a/source4/auth/ntlm/auth.c +++ b/source4/auth/ntlm/auth.c @@ -462,7 +462,7 @@ _PUBLIC_ NTSTATUS auth_register(const struct auth_operations *ops) struct auth_backend, num_backends+1); NT_STATUS_HAVE_NO_MEMORY(backends); - new_ops = talloc_memdup(backends, ops, sizeof(*ops)); + new_ops = (struct auth_operations *)talloc_memdup(backends, ops, sizeof(*ops)); NT_STATUS_HAVE_NO_MEMORY(new_ops); new_ops->name = talloc_strdup(new_ops, ops->name); NT_STATUS_HAVE_NO_MEMORY(new_ops->name); diff --git a/source4/auth/pyauth.h b/source4/auth/pyauth.h index de1c1c54ea6..f5c63392ac3 100644 --- a/source4/auth/pyauth.h +++ b/source4/auth/pyauth.h @@ -24,7 +24,7 @@ #include "auth/session.h" PyAPI_DATA(PyTypeObject) PyAuthSession; -#define PyAuthSession_AsSession(obj) py_talloc_get_ptr(obj) +#define PyAuthSession_AsSession(obj) py_talloc_get_type(obj, struct auth_session_info) #define PyAuthSession_Check(obj) PyObject_TypeCheck(obj, &PyAuthSession) struct auth_session_info *PyObject_AsSession(PyObject *obj); PyObject *PyAuthSession_FromSession(struct auth_session_info *session); diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index ef2af060f27..81b960979f6 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -51,8 +51,10 @@ void PyErr_SetLdbError(int ret, struct ldb_context *ldb_ctx) { if (ret == LDB_ERR_PYTHON_EXCEPTION) return; /* Python exception should already be set, just keep that */ - PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", ret, ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx))); + PyErr_SetObject(PyExc_LdbError, Py_BuildValue(discard_const_p(char, "(i,s)"), + ret, ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx))); } + static PyObject *PyObject_FromLdbValue(struct ldb_context *ldb_ctx, struct ldb_message_element *el, struct ldb_val *val) @@ -298,9 +300,11 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa PyObject *py_ldb; struct ldb_context *ldb_ctx; PyLdbDnObject *py_ret; - const char *kwnames[] = { "ldb", "dn", NULL }; + const char * const kwnames[] = { "ldb", "dn", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os", (char **)kwnames, &py_ldb, &str)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os", + discard_const_p(char *, kwnames), + &py_ldb, &str)) return NULL; ldb_ctx = PyLdb_AsLdbContext(py_ldb); @@ -361,8 +365,8 @@ PyTypeObject PyLdbDn = { static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3, 0); static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) { - PyObject *fn = context; - PyObject_CallFunction(fn, (char *)"(i,O)", level, PyString_FromFormatV(fmt, ap)); + PyObject *fn = (PyObject *)context; + PyObject_CallFunction(fn, discard_const_p(char, "(i,O)"), level, PyString_FromFormatV(fmt, ap)); } static PyObject *py_ldb_set_debug(PyLdbObject *self, PyObject *args) @@ -488,7 +492,7 @@ static const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list) static int py_ldb_init(PyLdbObject *self, PyObject *args, PyObject *kwargs) { - const char *kwnames[] = { "url", "flags", "options", NULL }; + const char * const kwnames[] = { "url", "flags", "options", NULL }; char *url = NULL; PyObject *py_options = Py_None; const char **options; @@ -496,8 +500,9 @@ static int py_ldb_init(PyLdbObject *self, PyObject *args, PyObject *kwargs) int ret; struct ldb_context *ldb; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ziO:Ldb.__init__", (char **)kwnames, - &url, &flags, &py_options)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ziO:Ldb.__init__", + discard_const_p(char *, kwnames), + &url, &flags, &py_options)) return -1; ldb = PyLdb_AsLdbContext(self); @@ -548,9 +553,11 @@ static PyObject *py_ldb_connect(PyLdbObject *self, PyObject *args, PyObject *kwa PyObject *py_options = Py_None; int ret; const char **options; - const char *kwnames[] = { "url", "flags", "options", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|iO", (char **)kwnames, &url, &flags, - &py_options)) + const char * const kwnames[] = { "url", "flags", "options", NULL }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|iO", + discard_const_p(char *, kwnames), + &url, &flags, &py_options)) return NULL; if (py_options == Py_None) { @@ -721,8 +728,9 @@ static PyObject *ldb_ldif_to_pyobject(struct ldb_ldif *ldif) } else { /* We don't want this attached to the 'ldb' any more */ talloc_steal(NULL, ldif); - return Py_BuildValue((char *)"(iO)", ldif->changetype, - PyLdbMessage_FromMessage(ldif->msg)); + return Py_BuildValue(discard_const_p(char, "(iO)"), + ldif->changetype, + PyLdbMessage_FromMessage(ldif->msg)); } } @@ -786,7 +794,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar char *expr = NULL; PyObject *py_attrs = Py_None; PyObject *py_controls = Py_None; - const char *kwnames[] = { "base", "scope", "expression", "attrs", "controls", NULL }; + const char * const kwnames[] = { "base", "scope", "expression", "attrs", "controls", NULL }; int ret; struct ldb_result *res; struct ldb_request *req; @@ -795,8 +803,9 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar struct ldb_control **parsed_controls; struct ldb_dn *base; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OizOO", (char **)kwnames, - &py_base, &scope, &expr, &py_attrs, &py_controls)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OizOO", + discard_const_p(char *, kwnames), + &py_base, &scope, &expr, &py_attrs, &py_controls)) return NULL; ldb_ctx = PyLdb_AsLdbContext(self); @@ -1009,7 +1018,7 @@ static PyObject *py_ldb_get_firstmodule(PyLdbObject *self, void *closure) } static PyGetSetDef py_ldb_getset[] = { - { (char *)"firstmodule", (getter)py_ldb_get_firstmodule, NULL, NULL }, + { discard_const_p(char, "firstmodule"), (getter)py_ldb_get_firstmodule, NULL, NULL }, { NULL } }; @@ -1109,10 +1118,12 @@ static PyObject *py_ldb_module_search(PyLdbModuleObject *self, PyObject *args, P PyObject *py_base, *py_tree, *py_attrs; int ret, scope; struct ldb_request *req; - const char *kwnames[] = { "base", "scope", "tree", "attrs", NULL }; + const char * const kwnames[] = { "base", "scope", "tree", "attrs", NULL }; struct ldb_module *mod; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiOO", (char **)kwnames, - &py_base, &scope, &py_tree, &py_attrs)) + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiOO", + discard_const_p(char *, kwnames), + &py_base, &scope, &py_tree, &py_attrs)) return NULL; mod = self->mod; @@ -1372,9 +1383,12 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb struct ldb_message_element *el; int flags = 0; char *name = NULL; - const char *kwnames[] = { "elements", "flags", "name", NULL }; + const char * const kwnames[] = { "elements", "flags", "name", NULL }; PyLdbMessageElementObject *ret; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Ois", (char **)kwnames, &py_elements, &flags, &name)) + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Ois", + discard_const_p(char *, kwnames), + &py_elements, &flags, &name)) return NULL; el = talloc_zero(NULL, struct ldb_message_element); @@ -1596,11 +1610,14 @@ static PyMappingMethods py_ldb_msg_mapping = { static PyObject *py_ldb_msg_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - const char *kwnames[] = { "dn", NULL }; + const char * const kwnames[] = { "dn", NULL }; struct ldb_message *ret; PyObject *pydn = NULL; PyLdbMessageObject *py_ret; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", (char **)kwnames, &pydn)) + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", + discard_const_p(char *, kwnames), + &pydn)) return NULL; ret = ldb_msg_new(NULL); @@ -1650,7 +1667,7 @@ static int py_ldb_msg_set_dn(PyLdbMessageObject *self, PyObject *value, void *cl } static PyGetSetDef py_ldb_msg_getset[] = { - { (char *)"dn", (getter)py_ldb_msg_get_dn, (setter)py_ldb_msg_set_dn, NULL }, + { discard_const_p(char, "dn"), (getter)py_ldb_msg_get_dn, (setter)py_ldb_msg_set_dn, NULL }, { NULL } }; @@ -1714,7 +1731,7 @@ PyTypeObject PyLdbTree = { /* Ldb_module */ static int py_module_search(struct ldb_module *mod, struct ldb_request *req) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result, *py_base, *py_attrs, *py_tree; py_base = PyLdbDn_FromDn(req->op.search.base); @@ -1737,7 +1754,9 @@ static int py_module_search(struct ldb_module *mod, struct ldb_request *req) PyList_SetItem(py_attrs, i, PyString_FromString(req->op.search.attrs[i])); } - py_result = PyObject_CallMethod(py_ldb, (char *)"search", (char *)"OiOO", py_base, req->op.search.scope, py_tree, py_attrs); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "search"), + discard_const_p(char, "OiOO"), + py_base, req->op.search.scope, py_tree, py_attrs); Py_DECREF(py_attrs); Py_DECREF(py_tree); @@ -1759,16 +1778,18 @@ static int py_module_search(struct ldb_module *mod, struct ldb_request *req) static int py_module_add(struct ldb_module *mod, struct ldb_request *req) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result, *py_msg; - py_msg = PyLdbMessage_FromMessage((struct ldb_message *)req->op.add.message); + py_msg = PyLdbMessage_FromMessage(discard_const_p(struct ldb_message, req->op.add.message)); if (py_msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - py_result = PyObject_CallMethod(py_ldb, (char *)"add", (char *)"O", py_msg); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "add"), + discard_const_p(char, "O"), + py_msg); Py_DECREF(py_msg); @@ -1783,16 +1804,18 @@ static int py_module_add(struct ldb_module *mod, struct ldb_request *req) static int py_module_modify(struct ldb_module *mod, struct ldb_request *req) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result, *py_msg; - py_msg = PyLdbMessage_FromMessage((struct ldb_message *)req->op.mod.message); + py_msg = PyLdbMessage_FromMessage(discard_const_p(struct ldb_message, req->op.mod.message)); if (py_msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - py_result = PyObject_CallMethod(py_ldb, (char *)"modify", (char *)"O", py_msg); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "modify"), + discard_const_p(char, "O"), + py_msg); Py_DECREF(py_msg); @@ -1807,7 +1830,7 @@ static int py_module_modify(struct ldb_module *mod, struct ldb_request *req) static int py_module_del(struct ldb_module *mod, struct ldb_request *req) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result, *py_dn; py_dn = PyLdbDn_FromDn(req->op.del.dn); @@ -1815,7 +1838,9 @@ static int py_module_del(struct ldb_module *mod, struct ldb_request *req) if (py_dn == NULL) return LDB_ERR_OPERATIONS_ERROR; - py_result = PyObject_CallMethod(py_ldb, (char *)"delete", (char *)"O", py_dn); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "delete"), + discard_const_p(char, "O"), + py_dn); if (py_result == NULL) { return LDB_ERR_PYTHON_EXCEPTION; @@ -1828,7 +1853,7 @@ static int py_module_del(struct ldb_module *mod, struct ldb_request *req) static int py_module_rename(struct ldb_module *mod, struct ldb_request *req) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result, *py_olddn, *py_newdn; py_olddn = PyLdbDn_FromDn(req->op.rename.olddn); @@ -1841,7 +1866,9 @@ static int py_module_rename(struct ldb_module *mod, struct ldb_request *req) if (py_newdn == NULL) return LDB_ERR_OPERATIONS_ERROR; - py_result = PyObject_CallMethod(py_ldb, (char *)"rename", (char *)"OO", py_olddn, py_newdn); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "rename"), + discard_const_p(char, "OO"), + py_olddn, py_newdn); Py_DECREF(py_olddn); Py_DECREF(py_newdn); @@ -1857,30 +1884,33 @@ static int py_module_rename(struct ldb_module *mod, struct ldb_request *req) static int py_module_request(struct ldb_module *mod, struct ldb_request *req) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result; - py_result = PyObject_CallMethod(py_ldb, (char *)"request", (char *)""); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "request"), + discard_const_p(char, "")); return LDB_ERR_OPERATIONS_ERROR; } static int py_module_extended(struct ldb_module *mod, struct ldb_request *req) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result; - py_result = PyObject_CallMethod(py_ldb, (char *)"extended", (char *)""); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "extended"), + discard_const_p(char, "")); return LDB_ERR_OPERATIONS_ERROR; } static int py_module_start_transaction(struct ldb_module *mod) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result; - py_result = PyObject_CallMethod(py_ldb, (char *)"start_transaction", (char *)""); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "start_transaction"), + discard_const_p(char, "")); if (py_result == NULL) { return LDB_ERR_PYTHON_EXCEPTION; @@ -1893,10 +1923,11 @@ static int py_module_start_transaction(struct ldb_module *mod) static int py_module_end_transaction(struct ldb_module *mod) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result; - py_result = PyObject_CallMethod(py_ldb, (char *)"end_transaction", (char *)""); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "end_transaction"), + discard_const_p(char, "")); if (py_result == NULL) { return LDB_ERR_PYTHON_EXCEPTION; @@ -1909,10 +1940,11 @@ static int py_module_end_transaction(struct ldb_module *mod) static int py_module_del_transaction(struct ldb_module *mod) { - PyObject *py_ldb = mod->private_data; + PyObject *py_ldb = (PyObject *)mod->private_data; PyObject *py_result; - py_result = PyObject_CallMethod(py_ldb, (char *)"del_transaction", (char *)""); + py_result = PyObject_CallMethod(py_ldb, discard_const_p(char, "del_transaction"), + discard_const_p(char, "")); if (py_result == NULL) { return LDB_ERR_PYTHON_EXCEPTION; @@ -1929,9 +1961,9 @@ static int py_module_destructor(struct ldb_module *mod) return 0; } -static int py_module_init (struct ldb_module *mod) +static int py_module_init(struct ldb_module *mod) { - PyObject *py_class = mod->ops->private_data; + PyObject *py_class = (PyObject *)mod->ops->private_data; PyObject *py_result, *py_next, *py_ldb; py_ldb = PyLdb_FromLdbContext(mod->ldb); @@ -1944,7 +1976,8 @@ static int py_module_init (struct ldb_module *mod) if (py_next == NULL) return LDB_ERR_OPERATIONS_ERROR; - py_result = PyObject_CallFunction(py_class, (char *)"OO", py_ldb, py_next); + py_result = PyObject_CallFunction(py_class, discard_const_p(char, "OO"), + py_ldb, py_next); if (py_result == NULL) { return LDB_ERR_PYTHON_EXCEPTION; @@ -1972,7 +2005,7 @@ static PyObject *py_register_module(PyObject *module, PyObject *args) return NULL; } - ops->name = talloc_strdup(ops, PyString_AsString(PyObject_GetAttrString(input, (char *)"name"))); + ops->name = talloc_strdup(ops, PyString_AsString(PyObject_GetAttrString(input, discard_const_p(char, "name")))); Py_INCREF(input); ops->private_data = input; @@ -2123,7 +2156,7 @@ void initldb(void) PyModule_AddObject(m, "__docformat__", PyString_FromString("restructuredText")); - PyExc_LdbError = PyErr_NewException((char *)"_ldb.LdbError", NULL, NULL); + PyExc_LdbError = PyErr_NewException(discard_const_p(char, "_ldb.LdbError"), NULL, NULL); PyModule_AddObject(m, "LdbError", PyExc_LdbError); Py_INCREF(&PyLdb); diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c index 26b57e4f450..e9801bb4250 100644 --- a/source4/lib/registry/patchfile_preg.c +++ b/source4/lib/registry/patchfile_preg.c @@ -64,7 +64,7 @@ static WERROR reg_preg_diff_set_value(void *_data, const char *key_name, const char *value_name, uint32_t value_type, DATA_BLOB value_data) { - struct preg_data *data = _data; + struct preg_data *data = (struct preg_data *)_data; uint32_t buf; preg_write_utf16(data->ic, data->fd, "["); @@ -86,12 +86,12 @@ static WERROR reg_preg_diff_set_value(void *_data, const char *key_name, static WERROR reg_preg_diff_del_key(void *_data, const char *key_name) { - struct preg_data *data = _data; + struct preg_data *data = (struct preg_data *)_data; char *parent_name; DATA_BLOB blob; parent_name = talloc_strndup(data->ctx, key_name, strrchr(key_name, '\\')-key_name); - blob.data = (void *)talloc_strndup(data->ctx, key_name+(strrchr(key_name, '\\')-key_name)+1, + blob.data = (uint8_t *)talloc_strndup(data->ctx, key_name+(strrchr(key_name, '\\')-key_name)+1, strlen(key_name)-(strrchr(key_name, '\\')-key_name)); blob.length = strlen((char *)blob.data)+1; @@ -103,13 +103,13 @@ static WERROR reg_preg_diff_del_key(void *_data, const char *key_name) static WERROR reg_preg_diff_del_value(void *_data, const char *key_name, const char *value_name) { - struct preg_data *data = _data; + struct preg_data *data = (struct preg_data *)_data; char *val; DATA_BLOB blob; val = talloc_asprintf(data->ctx, "**Del.%s", value_name); - blob.data = (void *)talloc(data->ctx, uint32_t); + blob.data = (uint8_t *)talloc(data->ctx, uint32_t); *(uint32_t *)blob.data = 0; blob.length = 4; return reg_preg_diff_set_value(data, key_name, val, REG_DWORD, blob); @@ -117,10 +117,10 @@ static WERROR reg_preg_diff_del_value(void *_data, const char *key_name, static WERROR reg_preg_diff_del_all_values(void *_data, const char *key_name) { - struct preg_data *data = _data; + struct preg_data *data = (struct preg_data *)_data; DATA_BLOB blob; - blob.data = (void *)talloc(data->ctx, uint32_t); + blob.data = (uint8_t *)talloc(data->ctx, uint32_t); *(uint32_t *)blob.data = 0; blob.length = 4; diff --git a/source4/lib/registry/pyregistry.c b/source4/lib/registry/pyregistry.c index 166543b6fdd..30becbb1bbc 100644 --- a/source4/lib/registry/pyregistry.c +++ b/source4/lib/registry/pyregistry.c @@ -18,29 +18,33 @@ */ #include "includes.h" +#include <tevent.h> #include <Python.h> #include "libcli/util/pyerrors.h" #include "lib/registry/registry.h" #include "scripting/python/modules.h" /* for py_iconv_convenience() */ #include <pytalloc.h> -#include <tevent.h> +#include "auth/credentials/pycredentials.h" #include "param/pyparam.h" #ifndef Py_RETURN_NONE #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None #endif -extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj); - PyAPI_DATA(PyTypeObject) PyRegistryKey; PyAPI_DATA(PyTypeObject) PyRegistry; PyAPI_DATA(PyTypeObject) PyHiveKey; +/*#define PyRegistryKey_AsRegistryKey(obj) py_talloc_get_type(obj, struct registry_key)*/ +#define PyRegistry_AsRegistryContext(obj) ((struct registry_context *)py_talloc_get_ptr(obj)) +#define PyHiveKey_AsHiveKey(obj) ((struct hive_key*)py_talloc_get_ptr(obj)) + + static PyObject *py_get_predefined_key_by_name(PyObject *self, PyObject *args) { char *name; WERROR result; - struct registry_context *ctx = py_talloc_get_ptr(self); + struct registry_context *ctx = PyRegistry_AsRegistryContext(self); struct registry_key *key; if (!PyArg_ParseTuple(args, "s", &name)) @@ -56,7 +60,7 @@ static PyObject *py_key_del_abs(PyObject *self, PyObject *args) { char *path; WERROR result; - struct registry_context *ctx = py_talloc_get_ptr(self); + struct registry_context *ctx = PyRegistry_AsRegistryContext(self); if (!PyArg_ParseTuple(args, "s", &path)) return NULL; @@ -70,7 +74,7 @@ static PyObject *py_key_del_abs(PyObject *self, PyObject *args) static PyObject *py_get_predefined_key(PyObject *self, PyObject *args) { uint32_t hkey; - struct registry_context *ctx = py_talloc_get_ptr(self); + struct registry_context *ctx = PyRegistry_AsRegistryContext(self); WERROR result; struct registry_key *key; @@ -87,7 +91,7 @@ static PyObject *py_diff_apply(PyObject *self, PyObject *args) { char *filename; WERROR result; - struct registry_context *ctx = py_talloc_get_ptr(self); + struct registry_context *ctx = PyRegistry_AsRegistryContext(self); if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; @@ -99,7 +103,7 @@ static PyObject *py_diff_apply(PyObject *self, PyObject *args) static PyObject *py_mount_hive(PyObject *self, PyObject *args) { - struct registry_context *ctx = py_talloc_get_ptr(self); + struct registry_context *ctx = PyRegistry_AsRegistryContext(self); uint32_t hkey; PyObject *py_hivekey, *py_elements = Py_None; const char **elements; @@ -124,7 +128,7 @@ static PyObject *py_mount_hive(PyObject *self, PyObject *args) SMB_ASSERT(ctx != NULL); - result = reg_mount_hive(ctx, py_talloc_get_ptr(py_hivekey), hkey, elements); + result = reg_mount_hive(ctx, PyHiveKey_AsHiveKey(py_hivekey), hkey, elements); PyErr_WERROR_IS_ERR_RAISE(result); Py_RETURN_NONE; @@ -166,7 +170,7 @@ PyTypeObject PyRegistry = { static PyObject *py_hive_key_del(PyObject *self, PyObject *args) { char *name; - struct hive_key *key = py_talloc_get_ptr(self); + struct hive_key *key = PyHiveKey_AsHiveKey(self); WERROR result; if (!PyArg_ParseTuple(args, "s", &name)) @@ -182,7 +186,7 @@ static PyObject *py_hive_key_del(PyObject *self, PyObject *args) static PyObject *py_hive_key_flush(PyObject *self) { WERROR result; - struct hive_key *key = py_talloc_get_ptr(self); + struct hive_key *key = PyHiveKey_AsHiveKey(self); result = hive_key_flush(key); PyErr_WERROR_IS_ERR_RAISE(result); @@ -194,7 +198,7 @@ static PyObject *py_hive_key_del_value(PyObject *self, PyObject *args) { char *name; WERROR result; - struct hive_key *key = py_talloc_get_ptr(self); + struct hive_key *key = PyHiveKey_AsHiveKey(self); if (!PyArg_ParseTuple(args, "s", &name)) return NULL; @@ -212,7 +216,7 @@ static PyObject *py_hive_key_set_value(PyObject *self, PyObject *args) uint32_t type; DATA_BLOB value; WERROR result; - struct hive_key *key = py_talloc_get_ptr(self); + struct hive_key *key = PyHiveKey_AsHiveKey(self); if (!PyArg_ParseTuple(args, "siz#", &name, &type, &value.data, &value.length)) return NULL; diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c index 4cbcb09a102..fbb9cd9de91 100644 --- a/source4/lib/registry/regf.c +++ b/source4/lib/registry/regf.c @@ -543,7 +543,7 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, struct hive_key *key, if (vk->data_length & 0x80000000) { vk->data_length &=~0x80000000; - data->data = talloc_memdup(ctx, (uint8_t *)&vk->data_offset, vk->data_length); + data->data = (uint8_t *)talloc_memdup(ctx, (uint8_t *)&vk->data_offset, vk->data_length); data->length = vk->data_length; } else { *data = hbin_get(regf, vk->data_offset); diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c index 9dcc415b7c9..e1d6b0e7a67 100644 --- a/source4/libcli/smb2/request.c +++ b/source4/libcli/smb2/request.c @@ -701,7 +701,7 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf, } if (*str == 0) { - blob.data = discard_const(str); + blob.data = discard_const_p(uint8_t, str); blob.length = 0; return smb2_push_o16s16_blob(buf, ofs, blob); } diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index 3e6ea313e75..2f1b14dc377 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -753,4 +753,6 @@ idl:: $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/lib/Parse/Pidl/Expr.pm @PIDL_OUTPUTDIR="../librpc/gen_ndr" PIDL_ARGS="$(PIDL_ARGS)" CPP="$(CPP)" srcdir="$(srcdir)" PIDL="$(PIDL)" ../librpc/build_idl.sh ../librpc/idl/*.idl @CPP="$(CPP)" PIDL="$(PIDL)" $(librpcsrcdir)/scripts/build_idl.sh PARTIAL $(librpcsrcdir)/gen_ndr $(librpcsrcdir)/idl/*.idl - +clean:: + @echo "Remove ../librpc/gen_ndr files which are not commited to git" + @cat ../.gitignore | grep "^librpc/gen_ndr" | xargs rm -f diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c index 371e111c674..252883c8517 100644 --- a/source4/librpc/rpc/pyrpc.c +++ b/source4/librpc/rpc/pyrpc.c @@ -29,7 +29,9 @@ #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None #endif -static PyObject *py_dcerpc_run_function(dcerpc_InterfaceObject *iface, struct PyNdrRpcMethodDef *md, PyObject *args, PyObject *kwargs) +static PyObject *py_dcerpc_run_function(dcerpc_InterfaceObject *iface, + const struct PyNdrRpcMethodDef *md, + PyObject *args, PyObject *kwargs) { TALLOC_CTX *mem_ctx; NTSTATUS status; @@ -74,7 +76,7 @@ static PyObject *py_dcerpc_run_function(dcerpc_InterfaceObject *iface, struct Py static PyObject *py_dcerpc_call_wrapper(PyObject *self, PyObject *args, void *wrapped, PyObject *kwargs) { dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)self; - struct PyNdrRpcMethodDef *md = wrapped; + const struct PyNdrRpcMethodDef *md = (const struct PyNdrRpcMethodDef *)wrapped; return py_dcerpc_run_function(iface, md, args, kwargs); } @@ -85,7 +87,7 @@ bool PyInterface_AddNdrRpcMethods(PyTypeObject *ifacetype, const struct PyNdrRpc int i; for (i = 0; mds[i].name; i++) { PyObject *ret; - struct wrapperbase *wb = calloc(sizeof(struct wrapperbase), 1); + struct wrapperbase *wb = (struct wrapperbase *)calloc(sizeof(struct wrapperbase), 1); wb->name = discard_const_p(char, mds[i].name); wb->flags = PyWrapperFlag_KEYWORDS; diff --git a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c index 134897e906e..073fd9992c4 100644 --- a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c +++ b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c @@ -127,43 +127,43 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC { struct dcerpc_server_info *server_info = lp_dcerpc_server_info(mem_ctx, server->ntptr->lp_ctx); if (strcmp("W3SvcInstalled", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; r->out.data.value = 0; return WERR_OK; } else if (strcmp("BeepEnabled", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; r->out.data.value = 0; return WERR_OK; } else if (strcmp("EventLog", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; r->out.data.value = 0; return WERR_OK; } else if (strcmp("NetPopup", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; r->out.data.value = 0; return WERR_OK; } else if (strcmp("NetPopupToComputer", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; r->out.data.value = 0; return WERR_OK; } else if (strcmp("MajorVersion", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; r->out.data.value = 3; return WERR_OK; } else if (strcmp("MinorVersion", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; r->out.data.value = 0; return WERR_OK; } else if (strcmp("DefaultSpoolDirectory", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_STRING; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_STRING; r->out.data.string = "C:\\PRINTERS"; return WERR_OK; } else if (strcmp("Architecture", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_STRING; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_STRING; r->out.data.string = SPOOLSS_ARCHITECTURE_NT_X86; return WERR_OK; } else if (strcmp("DsPresent", r->in.value_name) == 0) { - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_UINT32; r->out.data.value = 1; return WERR_OK; } else if (strcmp("OSVersion", r->in.value_name) == 0) { @@ -181,7 +181,7 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC return WERR_GENERAL_FAILURE; } - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_BINARY; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_BINARY; r->out.data.binary = blob; return WERR_OK; } else if (strcmp("OSVersionEx", r->in.value_name) == 0) { @@ -201,13 +201,13 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC return WERR_GENERAL_FAILURE; } - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_BINARY; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_BINARY; r->out.data.binary = blob; return WERR_OK; } else if (strcmp("DNSMachineName", r->in.value_name) == 0) { if (!lp_realm(server->ntptr->lp_ctx)) return WERR_INVALID_PARAM; - r->out.type = SPOOLSS_PRINTER_DATA_TYPE_STRING; + *r->out.type = SPOOLSS_PRINTER_DATA_TYPE_STRING; r->out.data.string = talloc_asprintf(mem_ctx, "%s.%s", lp_netbios_name(server->ntptr->lp_ctx), lp_realm(server->ntptr->lp_ctx)); diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c index d479f1e2ee0..1adced44aa4 100644 --- a/source4/ntvfs/posix/pvfs_acl.c +++ b/source4/ntvfs/posix/pvfs_acl.c @@ -51,7 +51,7 @@ NTSTATUS pvfs_acl_register(const struct pvfs_acl_ops *ops) backends = talloc_realloc(talloc_autofree_context(), backends, struct pvfs_acl_backend, num_backends+1); NT_STATUS_HAVE_NO_MEMORY(backends); - new_ops = talloc_memdup(backends, ops, sizeof(*ops)); + new_ops = (struct pvfs_acl_ops *)talloc_memdup(backends, ops, sizeof(*ops)); new_ops->name = talloc_strdup(new_ops, ops->name); backends[num_backends].ops = new_ops; diff --git a/source4/ntvfs/posix/pvfs_aio.c b/source4/ntvfs/posix/pvfs_aio.c index 56566e35925..e2028d00172 100644 --- a/source4/ntvfs/posix/pvfs_aio.c +++ b/source4/ntvfs/posix/pvfs_aio.c @@ -145,7 +145,7 @@ NTSTATUS pvfs_aio_pwrite(struct ntvfs_request *req, union smb_write *wr, state = talloc(req, struct pvfs_aio_write_state); NT_STATUS_HAVE_NO_MEMORY(state); - io_prep_pwrite(&iocb, f->handle->fd, wr->writex.in.data, + io_prep_pwrite(&iocb, f->handle->fd, discard_const(wr->writex.in.data), wr->writex.in.count, wr->writex.in.offset); state->ae = tevent_add_aio(req->ctx->event_ctx, req->ctx->event_ctx, &iocb, pvfs_aio_write_handler, state); diff --git a/source4/ntvfs/posix/pvfs_flush.c b/source4/ntvfs/posix/pvfs_flush.c index 6e09c1f34ae..f425fccec75 100644 --- a/source4/ntvfs/posix/pvfs_flush.c +++ b/source4/ntvfs/posix/pvfs_flush.c @@ -42,7 +42,8 @@ NTSTATUS pvfs_flush(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_flush *io) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f; switch (io->generic.level) { diff --git a/source4/ntvfs/posix/pvfs_fsinfo.c b/source4/ntvfs/posix/pvfs_fsinfo.c index 9a836fac323..10fb7cf707e 100644 --- a/source4/ntvfs/posix/pvfs_fsinfo.c +++ b/source4/ntvfs/posix/pvfs_fsinfo.c @@ -85,7 +85,8 @@ NTSTATUS pvfs_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { NTSTATUS status; - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); uint64_t blocks_free, blocks_total; uint_t bpunit; struct stat st; diff --git a/source4/ntvfs/posix/pvfs_ioctl.c b/source4/ntvfs/posix/pvfs_ioctl.c index 92d3eae061f..f263e9852b6 100644 --- a/source4/ntvfs/posix/pvfs_ioctl.c +++ b/source4/ntvfs/posix/pvfs_ioctl.c @@ -38,7 +38,8 @@ static NTSTATUS pvfs_ioctl_old(struct ntvfs_module_context *ntvfs, static NTSTATUS pvfs_ntioctl(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_ioctl *io) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f; f = pvfs_find_fd(pvfs, req, io->ntioctl.in.file.ntvfs); diff --git a/source4/ntvfs/posix/pvfs_lock.c b/source4/ntvfs/posix/pvfs_lock.c index 2353baeff4a..711c924ae3f 100644 --- a/source4/ntvfs/posix/pvfs_lock.c +++ b/source4/ntvfs/posix/pvfs_lock.c @@ -90,7 +90,8 @@ static void pvfs_lock_async_failed(struct pvfs_state *pvfs, */ static void pvfs_pending_lock_continue(void *private_data, enum pvfs_wait_notice reason) { - struct pvfs_pending_lock *pending = private_data; + struct pvfs_pending_lock *pending = talloc_get_type(private_data, + struct pvfs_pending_lock); struct pvfs_state *pvfs = pending->pvfs; struct pvfs_file *f = pending->f; struct ntvfs_request *req = pending->req; @@ -277,7 +278,8 @@ static NTSTATUS pvfs_lock_cancel(struct pvfs_state *pvfs, struct ntvfs_request * NTSTATUS pvfs_lock(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_lock *lck) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f; struct smb_lock_entry *locks; int i; diff --git a/source4/ntvfs/posix/pvfs_mkdir.c b/source4/ntvfs/posix/pvfs_mkdir.c index 8cc96173ad6..6ec9e60955d 100644 --- a/source4/ntvfs/posix/pvfs_mkdir.c +++ b/source4/ntvfs/posix/pvfs_mkdir.c @@ -96,7 +96,8 @@ static NTSTATUS pvfs_t2mkdir(struct pvfs_state *pvfs, NTSTATUS pvfs_mkdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_mkdir *md) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); NTSTATUS status; struct pvfs_filename *name; mode_t mode; @@ -153,7 +154,8 @@ NTSTATUS pvfs_mkdir(struct ntvfs_module_context *ntvfs, NTSTATUS pvfs_rmdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_rmdir *rd) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); NTSTATUS status; struct pvfs_filename *name; diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index fe3c915576f..12f50fcc97e 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -868,7 +868,8 @@ struct pvfs_odb_retry { /* destroy a pending request */ static int pvfs_odb_retry_destructor(struct pvfs_odb_retry *r) { - struct pvfs_state *pvfs = r->ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(r->ntvfs->private_data, + struct pvfs_state); if (r->odb_locking_key.data) { struct odb_lock *lck; lck = odb_lock(r->req, pvfs->odb_context, &r->odb_locking_key); @@ -913,7 +914,8 @@ NTSTATUS pvfs_odb_retry_setup(struct ntvfs_module_context *ntvfs, void *private_data, enum pvfs_wait_notice reason)) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_odb_retry *r; struct pvfs_wait *wait_handle; NTSTATUS status; @@ -1039,7 +1041,8 @@ static NTSTATUS pvfs_open_deny_dos(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_open *io, struct pvfs_file *f, struct odb_lock *lck) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f2; struct pvfs_filename *name; NTSTATUS status; @@ -1120,7 +1123,8 @@ static NTSTATUS pvfs_open_setup_retry(struct ntvfs_module_context *ntvfs, struct odb_lock *lck, NTSTATUS parent_status) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); NTSTATUS status; struct timeval end_time; struct timeval *final_timeout = NULL; @@ -1174,7 +1178,8 @@ static NTSTATUS pvfs_open_setup_retry(struct ntvfs_module_context *ntvfs, NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_open *io) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); int flags = 0; struct pvfs_filename *name; struct pvfs_file *f; @@ -1627,7 +1632,8 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs, NTSTATUS pvfs_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f; if (io->generic.level == RAW_CLOSE_SPLCLOSE) { @@ -1684,7 +1690,8 @@ NTSTATUS pvfs_close(struct ntvfs_module_context *ntvfs, NTSTATUS pvfs_logoff(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f, *next; for (f=pvfs->files.list;f;f=next) { @@ -1704,7 +1711,8 @@ NTSTATUS pvfs_logoff(struct ntvfs_module_context *ntvfs, NTSTATUS pvfs_exit(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f, *next; for (f=pvfs->files.list;f;f=next) { diff --git a/source4/ntvfs/posix/pvfs_oplock.c b/source4/ntvfs/posix/pvfs_oplock.c index 71add72987a..e5a069addcb 100644 --- a/source4/ntvfs/posix/pvfs_oplock.c +++ b/source4/ntvfs/posix/pvfs_oplock.c @@ -245,7 +245,8 @@ NTSTATUS pvfs_setup_oplock(struct pvfs_file *f, uint32_t oplock_granted) NTSTATUS pvfs_oplock_release(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_lock *lck) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f; uint8_t oplock_break; NTSTATUS status; diff --git a/source4/ntvfs/posix/pvfs_qfileinfo.c b/source4/ntvfs/posix/pvfs_qfileinfo.c index 3196cf2f8d6..bfc9a8441cb 100644 --- a/source4/ntvfs/posix/pvfs_qfileinfo.c +++ b/source4/ntvfs/posix/pvfs_qfileinfo.c @@ -338,7 +338,8 @@ static NTSTATUS pvfs_map_fileinfo(struct pvfs_state *pvfs, NTSTATUS pvfs_qpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_filename *name; NTSTATUS status; @@ -374,7 +375,8 @@ NTSTATUS pvfs_qpathinfo(struct ntvfs_module_context *ntvfs, NTSTATUS pvfs_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f; struct pvfs_file_handle *h; NTSTATUS status; diff --git a/source4/ntvfs/posix/pvfs_read.c b/source4/ntvfs/posix/pvfs_read.c index 8e1a59473f2..d9080d632d0 100644 --- a/source4/ntvfs/posix/pvfs_read.c +++ b/source4/ntvfs/posix/pvfs_read.c @@ -29,7 +29,8 @@ NTSTATUS pvfs_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *rd) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); ssize_t ret; struct pvfs_file *f; NTSTATUS status; diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c index ed90bf3d7bd..7f8eab5aa0b 100644 --- a/source4/ntvfs/posix/pvfs_rename.c +++ b/source4/ntvfs/posix/pvfs_rename.c @@ -103,7 +103,7 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx, char *dest, *d; /* the length is bounded by the length of the two strings combined */ - dest = talloc_size(mem_ctx, strlen(fname) + strlen(pattern) + 1); + dest = talloc_array(mem_ctx, char, strlen(fname) + strlen(pattern) + 1); if (dest == NULL) { return NULL; } @@ -133,6 +133,8 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx, *d = 0; + talloc_set_name_const(dest, dest); + return dest; } @@ -247,7 +249,8 @@ static NTSTATUS pvfs_rename_setup_retry(struct ntvfs_module_context *ntvfs, struct odb_lock *lck, NTSTATUS status) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct timeval end_time; if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { @@ -393,7 +396,8 @@ static NTSTATUS pvfs_rename_wildcard(struct pvfs_state *pvfs, static NTSTATUS pvfs_rename_mv(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_rename *ren) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); NTSTATUS status; struct pvfs_filename *name1, *name2; struct odb_lock *lck = NULL; @@ -470,7 +474,8 @@ static NTSTATUS pvfs_rename_stream(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_rename *ren, struct pvfs_filename *name1) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); NTSTATUS status; struct odb_lock *lck = NULL; @@ -522,7 +527,8 @@ static NTSTATUS pvfs_rename_stream(struct ntvfs_module_context *ntvfs, static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_rename *ren) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); NTSTATUS status; struct pvfs_filename *name1, *name2; struct odb_lock *lck = NULL; @@ -630,7 +636,8 @@ static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context *ntvfs, NTSTATUS pvfs_rename(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_rename *ren) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f; switch (ren->generic.level) { diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c index 43547c275b5..c33323350e0 100644 --- a/source4/ntvfs/posix/pvfs_resolve.c +++ b/source4/ntvfs/posix/pvfs_resolve.c @@ -464,7 +464,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, } /* rebuild the name */ - ret = talloc_size(mem_ctx, len+1); + ret = talloc_array(mem_ctx, char, len+1); if (ret == NULL) { talloc_free(s); return NT_STATUS_NO_MEMORY; @@ -478,6 +478,8 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, } ret[len] = 0; + talloc_set_name_const(ret, ret); + talloc_free(s); *fname = ret; diff --git a/source4/ntvfs/posix/pvfs_search.c b/source4/ntvfs/posix/pvfs_search.c index 22aa297210b..dc4f86b4d2c 100644 --- a/source4/ntvfs/posix/pvfs_search.c +++ b/source4/ntvfs/posix/pvfs_search.c @@ -294,8 +294,12 @@ static void pvfs_search_cleanup(struct pvfs_state *pvfs) time_t t = time(NULL); for (i=0;i<MAX_OLD_SEARCHES;i++) { - struct pvfs_search_state *search = idr_find(pvfs->search.idtree, i); - if (search == NULL) return; + struct pvfs_search_state *search; + void *p = idr_find(pvfs->search.idtree, i); + + if (p == NULL) return; + + search = talloc_get_type(p, struct pvfs_search_state); if (pvfs_list_eos(search->dir, search->current_index) && search->last_used != 0 && t > search->last_used + 30) { @@ -316,7 +320,8 @@ static NTSTATUS pvfs_search_first_old(struct ntvfs_module_context *ntvfs, bool (*callback)(void *, const union smb_search_data *)) { struct pvfs_dir *dir; - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_search_state *search; uint_t reply_count; uint16_t search_attrib; @@ -405,7 +410,9 @@ static NTSTATUS pvfs_search_next_old(struct ntvfs_module_context *ntvfs, void *search_private, bool (*callback)(void *, const union smb_search_data *)) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); + void *p; struct pvfs_search_state *search; struct pvfs_dir *dir; uint_t reply_count, max_count; @@ -415,12 +422,14 @@ static NTSTATUS pvfs_search_next_old(struct ntvfs_module_context *ntvfs, handle = io->search_next.in.id.handle | (io->search_next.in.id.reserved<<8); max_count = io->search_next.in.max_count; - search = idr_find(pvfs->search.idtree, handle); - if (search == NULL) { + p = idr_find(pvfs->search.idtree, handle); + if (p == NULL) { /* we didn't find the search handle */ return NT_STATUS_INVALID_HANDLE; } + search = talloc_get_type(p, struct pvfs_search_state); + dir = search->dir; status = pvfs_list_seek_ofs(dir, io->search_next.in.id.server_cookie, @@ -455,7 +464,8 @@ static NTSTATUS pvfs_search_first_trans2(struct ntvfs_module_context *ntvfs, bool (*callback)(void *, const union smb_search_data *)) { struct pvfs_dir *dir; - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_search_state *search; uint_t reply_count; uint16_t search_attrib, max_count; @@ -550,7 +560,9 @@ static NTSTATUS pvfs_search_next_trans2(struct ntvfs_module_context *ntvfs, void *search_private, bool (*callback)(void *, const union smb_search_data *)) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); + void *p; struct pvfs_search_state *search; struct pvfs_dir *dir; uint_t reply_count; @@ -559,12 +571,14 @@ static NTSTATUS pvfs_search_next_trans2(struct ntvfs_module_context *ntvfs, handle = io->t2fnext.in.handle; - search = idr_find(pvfs->search.idtree, handle); - if (search == NULL) { + p = idr_find(pvfs->search.idtree, handle); + if (p == NULL) { /* we didn't find the search handle */ return NT_STATUS_INVALID_HANDLE; } - + + search = talloc_get_type(p, struct pvfs_search_state); + dir = search->dir; status = NT_STATUS_OK; @@ -612,7 +626,8 @@ static NTSTATUS pvfs_search_first_smb2(struct ntvfs_module_context *ntvfs, bool (*callback)(void *, const union smb_search_data *)) { struct pvfs_dir *dir; - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_search_state *search; uint_t reply_count; uint16_t max_count; @@ -714,7 +729,8 @@ static NTSTATUS pvfs_search_next_smb2(struct ntvfs_module_context *ntvfs, void *search_private, bool (*callback)(void *, const union smb_search_data *)) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_search_state *search; uint_t reply_count; uint16_t max_count; @@ -812,7 +828,9 @@ NTSTATUS pvfs_search_next(struct ntvfs_module_context *ntvfs, NTSTATUS pvfs_search_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); + void *p; struct pvfs_search_state *search; uint16_t handle = INVALID_SEARCH_HANDLE; @@ -829,12 +847,14 @@ NTSTATUS pvfs_search_close(struct ntvfs_module_context *ntvfs, break; } - search = idr_find(pvfs->search.idtree, handle); - if (search == NULL) { + p = idr_find(pvfs->search.idtree, handle); + if (p == NULL) { /* we didn't find the search handle */ return NT_STATUS_INVALID_HANDLE; } + search = talloc_get_type(p, struct pvfs_search_state); + talloc_free(search); return NT_STATUS_OK; diff --git a/source4/ntvfs/posix/pvfs_seek.c b/source4/ntvfs/posix/pvfs_seek.c index a3c4024ed7e..2cd3410876a 100644 --- a/source4/ntvfs/posix/pvfs_seek.c +++ b/source4/ntvfs/posix/pvfs_seek.c @@ -29,7 +29,8 @@ NTSTATUS pvfs_seek(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_seek *io) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f; struct pvfs_file_handle *h; NTSTATUS status; diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c index d2604485d45..9fe02a8e175 100644 --- a/source4/ntvfs/posix/pvfs_setfileinfo.c +++ b/source4/ntvfs/posix/pvfs_setfileinfo.c @@ -308,7 +308,8 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *info) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_file *f; struct pvfs_file_handle *h; struct pvfs_filename newstats; @@ -609,7 +610,8 @@ static NTSTATUS pvfs_setpathinfo_setup_retry(struct ntvfs_module_context *ntvfs, struct odb_lock *lck, NTSTATUS status) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct timeval end_time; if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { @@ -632,7 +634,8 @@ static NTSTATUS pvfs_setpathinfo_setup_retry(struct ntvfs_module_context *ntvfs, NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *info) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_filename *name; struct pvfs_filename newstats; NTSTATUS status; diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c index 6a570417704..e10b2e3eef8 100644 --- a/source4/ntvfs/posix/pvfs_unlink.c +++ b/source4/ntvfs/posix/pvfs_unlink.c @@ -84,7 +84,8 @@ static NTSTATUS pvfs_unlink_setup_retry(struct ntvfs_module_context *ntvfs, struct odb_lock *lck, NTSTATUS status) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct timeval end_time; if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { @@ -191,7 +192,8 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_unlink *unl) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_dir *dir; NTSTATUS status; uint32_t total_deleted=0; diff --git a/source4/ntvfs/posix/pvfs_util.c b/source4/ntvfs/posix/pvfs_util.c index 09913bc9115..81ff20a6083 100644 --- a/source4/ntvfs/posix/pvfs_util.c +++ b/source4/ntvfs/posix/pvfs_util.c @@ -93,7 +93,7 @@ NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs, mode_t mode; NTSTATUS status; size_t buf_size = 0x10000; - char *buf = talloc_size(name2, buf_size); + uint8_t *buf = talloc_array(name2, uint8_t, buf_size); if (buf == NULL) { return NT_STATUS_NO_MEMORY; diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index d396b94da14..5552ab0d1b5 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -78,13 +78,12 @@ static void pvfs_wait_dispatch(struct messaging_context *msg, } pwait->reason = PVFS_WAIT_EVENT; - req = pwait->req; /* the extra reference here is to ensure that the req structure is not destroyed when the async request reply is sent, which would cause problems with the other ntvfs modules above us */ - talloc_reference(msg, req); + req = talloc_reference(msg, pwait->req); ntvfs_async_setup(pwait->req, pwait); talloc_unlink(msg, req); } @@ -185,7 +184,8 @@ struct pvfs_wait *pvfs_wait_message(struct pvfs_state *pvfs, */ NTSTATUS pvfs_cancel(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_wait *pwait; for (pwait=pvfs->wait_list;pwait;pwait=pwait->next) { diff --git a/source4/ntvfs/posix/pvfs_write.c b/source4/ntvfs/posix/pvfs_write.c index ba505e61d7c..fb629a87fb3 100644 --- a/source4/ntvfs/posix/pvfs_write.c +++ b/source4/ntvfs/posix/pvfs_write.c @@ -83,7 +83,8 @@ static void pvfs_trigger_write_time_update(struct pvfs_file_handle *h) NTSTATUS pvfs_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *wr) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); ssize_t ret; struct pvfs_file *f; NTSTATUS status; diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index 6b0f32e65a8..29ef701deeb 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -274,7 +274,8 @@ static NTSTATUS pvfs_chkpath(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_chkpath *cp) { - struct pvfs_state *pvfs = ntvfs->private_data; + struct pvfs_state *pvfs = talloc_get_type(ntvfs->private_data, + struct pvfs_state); struct pvfs_filename *name; NTSTATUS status; diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index 07f45d7cf6b..efaedf7b415 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -36,7 +36,7 @@ typedef inquiry lenfunc; #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None #endif -#define PyLoadparmContext_AsLoadparmContext(obj) py_talloc_get_ptr(obj) +#define PyLoadparmContext_AsLoadparmContext(obj) py_talloc_get_type(obj, struct loadparm_context) PyAPI_DATA(PyTypeObject) PyLoadparmContext; PyAPI_DATA(PyTypeObject) PyLoadparmService; @@ -149,7 +149,7 @@ static PyObject *py_lp_ctx_load(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; - ret = lp_load((struct loadparm_context *)self->ptr, filename); + ret = lp_load(PyLoadparmContext_AsLoadparmContext(self), filename); if (!ret) { PyErr_Format(PyExc_RuntimeError, "Unable to load file %s", filename); @@ -161,7 +161,7 @@ static PyObject *py_lp_ctx_load(py_talloc_Object *self, PyObject *args) static PyObject *py_lp_ctx_load_default(py_talloc_Object *self) { bool ret; - ret = lp_load_default(self->ptr); + ret = lp_load_default(PyLoadparmContext_AsLoadparmContext(self)); if (!ret) { PyErr_SetString(PyExc_RuntimeError, "Unable to load default file"); @@ -178,7 +178,7 @@ static PyObject *py_lp_ctx_get(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s|s", ¶m_name, §ion_name)) return NULL; - ret = py_lp_ctx_get_helper(self->ptr, section_name, param_name); + ret = py_lp_ctx_get_helper(PyLoadparmContext_AsLoadparmContext(self), section_name, param_name); if (ret == NULL) Py_RETURN_NONE; return ret; @@ -190,7 +190,7 @@ static PyObject *py_lp_ctx_is_myname(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s", &name)) return NULL; - return PyBool_FromLong(lp_is_myname(self->ptr, name)); + return PyBool_FromLong(lp_is_myname(PyLoadparmContext_AsLoadparmContext(self), name)); } static PyObject *py_lp_ctx_is_mydomain(py_talloc_Object *self, PyObject *args) @@ -199,7 +199,7 @@ static PyObject *py_lp_ctx_is_mydomain(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s", &name)) return NULL; - return PyBool_FromLong(lp_is_mydomain(self->ptr, name)); + return PyBool_FromLong(lp_is_mydomain(PyLoadparmContext_AsLoadparmContext(self), name)); } static PyObject *py_lp_ctx_set(py_talloc_Object *self, PyObject *args) @@ -209,7 +209,7 @@ static PyObject *py_lp_ctx_set(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "ss", &name, &value)) return NULL; - ret = lp_set_cmdline(self->ptr, name, value); + ret = lp_set_cmdline(PyLoadparmContext_AsLoadparmContext(self), name, value); if (!ret) { PyErr_SetString(PyExc_RuntimeError, "Unable to set parameter"); return NULL; @@ -225,7 +225,7 @@ static PyObject *py_lp_ctx_private_path(py_talloc_Object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s", &name)) return NULL; - path = private_path(NULL, self->ptr, name); + path = private_path(NULL, PyLoadparmContext_AsLoadparmContext(self), name); ret = PyString_FromString(path); talloc_free(path); @@ -258,12 +258,12 @@ static PyMethodDef py_lp_ctx_methods[] = { static PyObject *py_lp_ctx_default_service(py_talloc_Object *self, void *closure) { - return PyLoadparmService_FromService(lp_default_service((struct loadparm_context *)self->ptr)); + return PyLoadparmService_FromService(lp_default_service(PyLoadparmContext_AsLoadparmContext(self))); } static PyObject *py_lp_ctx_config_file(py_talloc_Object *self, void *closure) { - const char *configfile = lp_configfile(self->ptr); + const char *configfile = lp_configfile(PyLoadparmContext_AsLoadparmContext(self)); if (configfile == NULL) Py_RETURN_NONE; else @@ -271,9 +271,9 @@ static PyObject *py_lp_ctx_config_file(py_talloc_Object *self, void *closure) } static PyGetSetDef py_lp_ctx_getset[] = { - { (char *)"default_service", (getter)py_lp_ctx_default_service, NULL, NULL }, - { (char *)"configfile", (getter)py_lp_ctx_config_file, NULL, - (char *)"Name of last config file that was loaded." }, + { discard_const_p(char, "default_service"), (getter)py_lp_ctx_default_service, NULL, NULL }, + { discard_const_p(char, "configfile"), (getter)py_lp_ctx_config_file, NULL, + discard_const_p(char, "Name of last config file that was loaded.") }, { NULL } }; @@ -284,7 +284,7 @@ static PyObject *py_lp_ctx_new(PyTypeObject *type, PyObject *args, PyObject *kwa static Py_ssize_t py_lp_ctx_len(py_talloc_Object *self) { - return lp_numservices(self->ptr); + return lp_numservices(PyLoadparmContext_AsLoadparmContext(self)); } static PyObject *py_lp_ctx_getitem(py_talloc_Object *self, PyObject *name) @@ -294,7 +294,7 @@ static PyObject *py_lp_ctx_getitem(py_talloc_Object *self, PyObject *name) PyErr_SetString(PyExc_TypeError, "Only string subscripts are supported"); return NULL; } - service = lp_service(self->ptr, PyString_AsString(name)); + service = lp_service(PyLoadparmContext_AsLoadparmContext(self), PyString_AsString(name)); if (service == NULL) { PyErr_SetString(PyExc_KeyError, "No such section"); return NULL; diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c index 1317dba1a40..e13749754f6 100644 --- a/source4/rpc_server/spoolss/dcesrv_spoolss.c +++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c @@ -41,7 +41,7 @@ enum spoolss_handle { #define SPOOLSS_BUFFER_UNION_ARRAY(fn,ic,info,level,count) \ ((info)?ndr_size_##fn##_info(dce_call, ic, level, count, info):0) -#define SPOOLSS_BUFFER_OK(val_true,val_false) ((r->in.offered >= r->out.needed)?val_true:val_false) +#define SPOOLSS_BUFFER_OK(val_true,val_false) ((r->in.offered >= *r->out.needed)?val_true:val_false) static WERROR dcesrv_spoolss_parse_printer_name(TALLOC_CTX *mem_ctx, const char *name, const char **_server_name, @@ -243,7 +243,7 @@ static WERROR dcesrv_spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TA status = ntptr_EnumPrinters(ntptr, mem_ctx, r); W_ERROR_NOT_OK_RETURN(status); - r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPrinters, ic, r->out.info, r->in.level, r->out.count); + *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPrinters, ic, r->out.info, r->in.level, r->out.count); r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); r->out.count = SPOOLSS_BUFFER_OK(r->out.count, 0); return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); @@ -379,7 +379,7 @@ static WERROR dcesrv_spoolss_EnumPrinterDrivers(struct dcesrv_call_state *dce_ca status = ntptr_EnumPrinterDrivers(ntptr, mem_ctx, r); W_ERROR_NOT_OK_RETURN(status); - r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPrinterDrivers, ic, r->out.info, r->in.level, r->out.count); + *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPrinterDrivers, ic, r->out.info, r->in.level, r->out.count); r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); r->out.count = SPOOLSS_BUFFER_OK(r->out.count, 0); return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); @@ -412,7 +412,7 @@ static WERROR dcesrv_spoolss_GetPrinterDriverDirectory(struct dcesrv_call_state status = ntptr_GetPrinterDriverDirectory(ntptr, mem_ctx, r); W_ERROR_NOT_OK_RETURN(status); - r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_DriverDirectoryInfo, ic, r->out.info, r->in.level); + *r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_DriverDirectoryInfo, ic, r->out.info, r->in.level); r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); } @@ -564,6 +564,9 @@ static WERROR dcesrv_spoolss_GetPrinterData(struct dcesrv_call_state *dce_call, if (!handle) return WERR_BADFID; + r->out.type = talloc_zero(mem_ctx, enum spoolss_PrinterDataType); + W_ERROR_HAVE_NO_MEMORY(r->out.type); + switch (handle->type) { case NTPTR_HANDLE_SERVER: status = ntptr_GetPrintServerData(handle, mem_ctx, r); @@ -575,8 +578,8 @@ static WERROR dcesrv_spoolss_GetPrinterData(struct dcesrv_call_state *dce_call, W_ERROR_NOT_OK_RETURN(status); - r->out.needed = ndr_size_spoolss_PrinterData(&r->out.data, r->out.type, ic, 0); - r->out.type = SPOOLSS_BUFFER_OK(r->out.type, SPOOLSS_PRINTER_DATA_TYPE_NULL); + *r->out.needed = ndr_size_spoolss_PrinterData(&r->out.data, *r->out.type, ic, 0); + *r->out.type = SPOOLSS_BUFFER_OK(*r->out.type, SPOOLSS_PRINTER_DATA_TYPE_NULL); r->out.data = SPOOLSS_BUFFER_OK(r->out.data, r->out.data); return SPOOLSS_BUFFER_OK(WERR_OK, WERR_MORE_DATA); } @@ -716,7 +719,7 @@ static WERROR dcesrv_spoolss_GetForm(struct dcesrv_call_state *dce_call, TALLOC_ return WERR_FOOBAR; } - r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_FormInfo, ic, r->out.info, r->in.level); + *r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_FormInfo, ic, r->out.info, r->in.level); r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); } @@ -783,7 +786,7 @@ static WERROR dcesrv_spoolss_EnumForms(struct dcesrv_call_state *dce_call, TALLO return WERR_FOOBAR; } - r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumForms, ic, r->out.info, r->in.level, r->out.count); + *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumForms, ic, r->out.info, r->in.level, r->out.count); r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); r->out.count = SPOOLSS_BUFFER_OK(r->out.count, 0); return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); @@ -806,7 +809,7 @@ static WERROR dcesrv_spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLO status = ntptr_EnumPorts(ntptr, mem_ctx, r); W_ERROR_NOT_OK_RETURN(status); - r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPorts, ic, r->out.info, r->in.level, r->out.count); + *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPorts, ic, r->out.info, r->in.level, r->out.count); r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); r->out.count = SPOOLSS_BUFFER_OK(r->out.count, 0); return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); @@ -829,7 +832,7 @@ static WERROR dcesrv_spoolss_EnumMonitors(struct dcesrv_call_state *dce_call, TA status = ntptr_EnumMonitors(ntptr, mem_ctx, r); W_ERROR_NOT_OK_RETURN(status); - r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumMonitors, ic, r->out.info, r->in.level, r->out.count); + *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumMonitors, ic, r->out.info, r->in.level, r->out.count); r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL); r->out.count = SPOOLSS_BUFFER_OK(r->out.count, 0); return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER); diff --git a/source4/selftest/skip b/source4/selftest/skip index f1500ff3153..291ad8472dc 100644 --- a/source4/selftest/skip +++ b/source4/selftest/skip @@ -42,7 +42,6 @@ ntvfs.cifs.raw.context ntvfs.cifs.raw.qfileinfo.ipc rpc.dssync rpc.samsync -ldap.uptodatevector # Segfaults rpc.remact # Not provided by Samba 4 rpc.oxidresolve # Not provided by Samba 4 rpc.eventlog # Not provided by Samba 4 diff --git a/source4/torture/ldap/uptodatevector.c b/source4/torture/ldap/uptodatevector.c index 6200f4c3de7..bf32edb0652 100644 --- a/source4/torture/ldap/uptodatevector.c +++ b/source4/torture/ldap/uptodatevector.c @@ -127,6 +127,7 @@ static bool test_check_uptodatevector(struct torture_context *torture, no_match = true; } else if (utdv_val1 && !utdv_val) { no_match = true; + } else if (!utdv_val1 && !utdv_val) { } else if (utdv_val1->length != utdv_val->length) { no_match = true; } else if (utdv_val1->length && memcmp(utdv_val1->data, utdv_val->data, utdv_val->length) != 0) { diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 5b493db813f..5f803b07d39 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -2617,12 +2617,14 @@ static bool enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe, struct spoolss_EnumPrinters r; NTSTATUS status; DATA_BLOB blob; + uint32_t needed; r.in.flags = PRINTER_ENUM_LOCAL; r.in.server = talloc_asprintf(mem_ctx, "\\\\%s", servername); r.in.level = level; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; status = dcerpc_spoolss_EnumPrinters(pipe, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -2638,14 +2640,14 @@ static bool enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe, return false; } - blob = data_blob_talloc_zero(mem_ctx, r.out.needed); + blob = data_blob_talloc_zero(mem_ctx, needed); if (blob.data == NULL) { d_printf("(%s) data_blob_talloc failed\n", __location__); return false; } r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumPrinters(pipe, mem_ctx, &r); if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { @@ -2668,6 +2670,7 @@ static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe, struct spoolss_GetPrinter r; DATA_BLOB blob; NTSTATUS status; + uint32_t needed; mem_ctx = talloc_new(ctx); if (mem_ctx == NULL) { @@ -2678,6 +2681,7 @@ static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe, r.in.level = level; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; status = dcerpc_spoolss_GetPrinter(pipe, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -2697,14 +2701,14 @@ static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe, r.in.handle = handle; r.in.level = level; - blob = data_blob_talloc(mem_ctx, NULL, r.out.needed); + blob = data_blob_talloc(mem_ctx, NULL, needed); if (blob.data == NULL) { talloc_free(mem_ctx); return NT_STATUS_NO_MEMORY; } memset(blob.data, 0, blob.length); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_GetPrinter(pipe, mem_ctx, &r); if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 4a6ff480c47..7da3209eb3c 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -106,11 +106,13 @@ static bool test_EnumPorts(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; DATA_BLOB blob; + uint32_t needed; r.in.servername = ""; r.in.level = level; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumPorts level %u\n", r.in.level); @@ -123,10 +125,10 @@ static bool test_EnumPorts(struct torture_context *tctx, torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, "EnumPorts unexpected return code"); - blob = data_blob_talloc(ctx, NULL, r.out.needed); + blob = data_blob_talloc(ctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumPorts(p, ctx, &r); torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPorts failed"); @@ -191,6 +193,7 @@ static bool test_GetPrinterDriverDirectory(struct torture_context *tctx, } }; int i; + uint32_t needed; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i].level; @@ -201,6 +204,7 @@ static bool test_GetPrinterDriverDirectory(struct torture_context *tctx, r.in.level = level; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing GetPrinterDriverDirectory level %u\n", r.in.level); @@ -210,10 +214,10 @@ static bool test_GetPrinterDriverDirectory(struct torture_context *tctx, torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, "GetPrinterDriverDirectory unexpected return code"); - blob = data_blob_talloc(ctx, NULL, r.out.needed); + blob = data_blob_talloc(ctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_GetPrinterDriverDirectory(p, ctx, &r); torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_GetPrinterDriverDirectory failed"); @@ -236,12 +240,14 @@ static bool test_EnumPrinterDrivers(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; DATA_BLOB blob; + uint32_t needed; r.in.server = ""; r.in.environment = SPOOLSS_ARCHITECTURE_NT_X86; r.in.level = level; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumPrinterDrivers level %u\n", r.in.level); @@ -255,10 +261,10 @@ static bool test_EnumPrinterDrivers(struct torture_context *tctx, torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, "EnumPrinterDrivers failed"); - blob = data_blob_talloc(ctx, NULL, r.out.needed); + blob = data_blob_talloc(ctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumPrinterDrivers(p, ctx, &r); torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinterDrivers failed"); @@ -351,11 +357,13 @@ static bool test_EnumMonitors(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; DATA_BLOB blob; + uint32_t needed; r.in.servername = ""; r.in.level = level; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumMonitors level %u\n", r.in.level); @@ -368,10 +376,10 @@ static bool test_EnumMonitors(struct torture_context *tctx, torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, "EnumMonitors failed"); - blob = data_blob_talloc(ctx, NULL, r.out.needed); + blob = data_blob_talloc(ctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumMonitors(p, ctx, &r); torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumMonitors failed"); @@ -420,12 +428,14 @@ static bool test_EnumPrintProcessors(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; DATA_BLOB blob; + uint32_t needed; r.in.servername = ""; r.in.environment = "Windows NT x86"; r.in.level = level; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumPrintProcessors level %u\n", r.in.level); @@ -438,10 +448,10 @@ static bool test_EnumPrintProcessors(struct torture_context *tctx, torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, "EnumPrintProcessors unexpected return code"); - blob = data_blob_talloc(ctx, NULL, r.out.needed); + blob = data_blob_talloc(ctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumPrintProcessors(p, ctx, &r); torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrintProcessors failed"); @@ -489,12 +499,14 @@ static bool test_EnumPrinters(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; DATA_BLOB blob; + uint32_t needed; r.in.flags = PRINTER_ENUM_LOCAL; r.in.server = ""; r.in.level = level; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumPrinters level %u\n", r.in.level); @@ -507,10 +519,10 @@ static bool test_EnumPrinters(struct torture_context *tctx, torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, "EnumPrinters unexpected return code"); - blob = data_blob_talloc(ctx, NULL, r.out.needed); + blob = data_blob_talloc(ctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumPrinters(p, ctx, &r); torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinters failed"); @@ -605,12 +617,14 @@ static bool test_GetPrinter(struct torture_context *tctx, struct spoolss_GetPrinter r; uint16_t levels[] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; int i; + uint32_t needed; for (i=0;i<ARRAY_SIZE(levels);i++) { r.in.handle = handle; r.in.level = levels[i]; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing GetPrinter level %u\n", r.in.level); @@ -618,10 +632,10 @@ static bool test_GetPrinter(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_GetPrinter(p, tctx, &r); } @@ -659,12 +673,14 @@ static bool test_GetForm(struct torture_context *tctx, { NTSTATUS status; struct spoolss_GetForm r; + uint32_t needed; r.in.handle = handle; r.in.form_name = form_name; r.in.level = 1; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing GetForm\n"); @@ -672,10 +688,10 @@ static bool test_GetForm(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "GetForm failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_GetForm(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "GetForm failed"); @@ -696,11 +712,13 @@ static bool test_EnumForms(struct torture_context *tctx, NTSTATUS status; struct spoolss_EnumForms r; bool ret = true; + uint32_t needed; r.in.handle = handle; r.in.level = 1; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumForms\n"); @@ -713,10 +731,10 @@ static bool test_EnumForms(struct torture_context *tctx, if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { union spoolss_FormInfo *info; int j; - DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumForms(p, tctx, &r); @@ -823,12 +841,14 @@ static bool test_EnumPorts_old(struct torture_context *tctx, { NTSTATUS status; struct spoolss_EnumPorts r; + uint32_t needed; r.in.servername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.level = 2; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumPorts\n"); @@ -837,10 +857,10 @@ static bool test_EnumPorts_old(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "EnumPorts failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumPorts(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "EnumPorts failed"); @@ -888,12 +908,14 @@ static bool test_GetJob(struct torture_context *tctx, { NTSTATUS status; struct spoolss_GetJob r; + uint32_t needed; r.in.handle = handle; r.in.job_id = job_id; r.in.level = 1; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing GetJob\n"); @@ -901,10 +923,10 @@ static bool test_GetJob(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "GetJob failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_GetJob(p, tctx, &r); @@ -942,6 +964,7 @@ static bool test_EnumJobs(struct torture_context *tctx, { NTSTATUS status; struct spoolss_EnumJobs r; + uint32_t needed; r.in.handle = handle; r.in.firstjob = 0; @@ -949,6 +972,7 @@ static bool test_EnumJobs(struct torture_context *tctx, r.in.level = 1; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumJobs\n"); @@ -959,10 +983,10 @@ static bool test_EnumJobs(struct torture_context *tctx, if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { union spoolss_JobInfo *info; int j; - DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumJobs(p, tctx, &r); @@ -997,12 +1021,14 @@ static bool test_DoPrintTest(struct torture_context *tctx, struct spoolss_EndDocPrinter e; int i; uint32_t job_id; + uint32_t num_written; torture_comment(tctx, "Testing StartDocPrinter\n"); s.in.handle = handle; s.in.level = 1; s.in.info.info1 = &info1; + s.out.job_id = &job_id; info1.document_name = "TorturePrintJob"; info1.output_file = NULL; info1.datatype = "RAW"; @@ -1011,8 +1037,6 @@ static bool test_DoPrintTest(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_StartDocPrinter failed"); torture_assert_werr_ok(tctx, s.out.result, "StartDocPrinter failed"); - job_id = s.out.job_id; - for (i=1; i < 4; i++) { torture_comment(tctx, "Testing StartPagePrinter: Page[%d]\n", i); @@ -1027,6 +1051,7 @@ static bool test_DoPrintTest(struct torture_context *tctx, w.in.handle = handle; w.in.data = data_blob_string_const(talloc_asprintf(tctx,"TortureTestPage: %d\nData\n",i)); + w.out.num_written = &num_written; status = dcerpc_spoolss_WritePrinter(p, tctx, &w); torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_WritePrinter failed"); @@ -1113,10 +1138,14 @@ static bool test_GetPrinterData(struct torture_context *tctx, { NTSTATUS status; struct spoolss_GetPrinterData r; + uint32_t needed; + enum spoolss_PrinterDataType type; r.in.handle = handle; r.in.value_name = value_name; r.in.offered = 0; + r.out.needed = &needed; + r.out.type = &type; torture_comment(tctx, "Testing GetPrinterData\n"); @@ -1124,7 +1153,7 @@ static bool test_GetPrinterData(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed"); if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) { - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_GetPrinterData(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed"); @@ -1143,11 +1172,15 @@ static bool test_GetPrinterDataEx(struct torture_context *tctx, { NTSTATUS status; struct spoolss_GetPrinterDataEx r; + uint32_t type; + uint32_t needed; r.in.handle = handle; r.in.key_name = key_name; r.in.value_name = value_name; r.in.offered = 0; + r.out.type = &type; + r.out.needed = &needed; torture_comment(tctx, "Testing GetPrinterDataEx\n"); @@ -1161,7 +1194,8 @@ static bool test_GetPrinterDataEx(struct torture_context *tctx, } if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) { - r.in.offered = r.out.needed; + r.in.offered = needed; + r.out.buffer = talloc_array(tctx, uint8_t, needed); status = dcerpc_spoolss_GetPrinterDataEx(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "GetPrinterDataEx failed"); @@ -1228,17 +1262,22 @@ static bool test_EnumPrinterDataEx(struct torture_context *tctx, { NTSTATUS status; struct spoolss_EnumPrinterDataEx r; + uint32_t needed; + uint32_t count; r.in.handle = handle; r.in.key_name = "PrinterDriverData"; r.in.offered = 0; + r.out.needed = &needed; + r.out.count = &count; torture_comment(tctx, "Testing EnumPrinterDataEx\n"); status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed"); - r.in.offered = r.out.needed; + r.in.offered = needed; + r.out.buffer = talloc_array(tctx, uint8_t, needed); status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r); @@ -1539,12 +1578,14 @@ static bool test_EnumPrinters_old(struct torture_context *tctx, struct dcerpc_pi for (i=0;i<ARRAY_SIZE(levels);i++) { union spoolss_PrinterInfo *info; int j; + uint32_t needed; r.in.flags = PRINTER_ENUM_LOCAL; r.in.server = ""; r.in.level = levels[i]; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumPrinters level %u\n", r.in.level); @@ -1552,10 +1593,10 @@ static bool test_EnumPrinters_old(struct torture_context *tctx, struct dcerpc_pi torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumPrinters(p, tctx, &r); } @@ -1596,6 +1637,9 @@ static bool test_GetPrinterDriver2(struct dcerpc_pipe *p, { NTSTATUS status; struct spoolss_GetPrinterDriver2 r; + uint32_t needed; + uint32_t server_major_version; + uint32_t server_minor_version; r.in.handle = handle; r.in.architecture = "W32X86"; @@ -1604,6 +1648,9 @@ static bool test_GetPrinterDriver2(struct dcerpc_pipe *p, r.in.offered = 0; r.in.client_major_version = 0; r.in.client_minor_version = 0; + r.out.needed = &needed; + r.out.server_major_version = &server_major_version; + r.out.server_minor_version = &server_minor_version; printf("Testing GetPrinterDriver2\n"); @@ -1614,7 +1661,7 @@ static bool test_GetPrinterDriver2(struct dcerpc_pipe *p, } if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r); } @@ -1644,11 +1691,14 @@ static bool test_EnumPrinterDrivers_old(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { + uint32_t needed; + r.in.server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.environment = "Windows NT x86"; r.in.level = levels[i]; r.in.buffer = NULL; r.in.offered = 0; + r.out.needed = &needed; torture_comment(tctx, "Testing EnumPrinterDrivers level %u\n", r.in.level); @@ -1657,10 +1707,10 @@ static bool test_EnumPrinterDrivers_old(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDrivers failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); data_blob_clear(&blob); r.in.buffer = &blob; - r.in.offered = r.out.needed; + r.in.offered = needed; status = dcerpc_spoolss_EnumPrinterDrivers(p, tctx, &r); } diff --git a/source4/torture/rpc/spoolss_win.c b/source4/torture/rpc/spoolss_win.c index ca61d1dddb5..df0ab65f3a9 100644 --- a/source4/torture/rpc/spoolss_win.c +++ b/source4/torture/rpc/spoolss_win.c @@ -155,11 +155,15 @@ static bool test_GetPrinterData(struct torture_context *tctx, { NTSTATUS status; struct spoolss_GetPrinterData gpd; + uint32_t needed; + enum spoolss_PrinterDataType type; torture_comment(tctx, "Testing GetPrinterData(%s).\n", value_name); gpd.in.handle = handle; gpd.in.value_name = value_name; gpd.in.offered = 4; + gpd.out.needed = &needed; + gpd.out.type = &type; status = dcerpc_spoolss_GetPrinterData(p, tctx, &gpd); torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed."); @@ -182,20 +186,22 @@ static bool test_EnumPrinters(struct torture_context *tctx, NTSTATUS status; struct spoolss_EnumPrinters ep; DATA_BLOB blob = data_blob_talloc_zero(ctx, initial_blob_size); + uint32_t needed; ep.in.flags = PRINTER_ENUM_NAME; ep.in.server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); ep.in.level = 2; ep.in.buffer = &blob; ep.in.offered = initial_blob_size; + ep.out.needed = &needed; status = dcerpc_spoolss_EnumPrinters(p, ctx, &ep); torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed."); if (W_ERROR_EQUAL(ep.out.result, WERR_INSUFFICIENT_BUFFER)) { - blob = data_blob_talloc_zero(ctx, ep.out.needed); + blob = data_blob_talloc_zero(ctx, needed); ep.in.buffer = &blob; - ep.in.offered = ep.out.needed; + ep.in.offered = needed; status = dcerpc_spoolss_EnumPrinters(p, ctx, &ep); torture_assert_ntstatus_ok(tctx, status,"EnumPrinters failed."); } @@ -220,6 +226,7 @@ static bool test_GetPrinter(struct torture_context *tctx, NTSTATUS status; struct spoolss_GetPrinter gp; DATA_BLOB blob = data_blob_talloc_zero(ctx, initial_blob_size); + uint32_t needed; torture_comment(tctx, "Test GetPrinter level %d\n", level); @@ -227,14 +234,15 @@ static bool test_GetPrinter(struct torture_context *tctx, gp.in.level = level; gp.in.buffer = (initial_blob_size == 0)?NULL:&blob; gp.in.offered = initial_blob_size; + gp.out.needed = &needed; status = dcerpc_spoolss_GetPrinter(p, tctx, &gp); torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed"); if (W_ERROR_EQUAL(gp.out.result, WERR_INSUFFICIENT_BUFFER)) { - blob = data_blob_talloc_zero(ctx, gp.out.needed); + blob = data_blob_talloc_zero(ctx, needed); gp.in.buffer = &blob; - gp.in.offered = gp.out.needed; + gp.in.offered = needed; status = dcerpc_spoolss_GetPrinter(p, tctx, &gp); torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed"); } @@ -252,6 +260,7 @@ static bool test_EnumJobs(struct torture_context *tctx, NTSTATUS status; struct spoolss_EnumJobs ej; DATA_BLOB blob = data_blob_talloc_zero(tctx, 1024); + uint32_t needed; torture_comment(tctx, "Test EnumJobs\n"); @@ -259,6 +268,7 @@ static bool test_EnumJobs(struct torture_context *tctx, ej.in.level = 2; ej.in.buffer = &blob; ej.in.offered = 1024; + ej.out.needed = &needed; status = dcerpc_spoolss_EnumJobs(p, tctx, &ej); torture_assert_ntstatus_ok(tctx, status, "EnumJobs failed"); @@ -274,6 +284,9 @@ static bool test_GetPrinterDriver2(struct torture_context *tctx, NTSTATUS status; struct spoolss_GetPrinterDriver2 gpd2; DATA_BLOB blob = data_blob_talloc_zero(tctx, 87424); + uint32_t needed; + uint32_t server_major_version; + uint32_t server_minor_version; torture_comment(tctx, "Testing GetPrinterDriver2\n"); @@ -284,6 +297,9 @@ static bool test_GetPrinterDriver2(struct torture_context *tctx, gpd2.in.offered = 87424; gpd2.in.client_major_version = 3; gpd2.in.client_minor_version = 0; + gpd2.out.needed = &needed; + gpd2.out.server_major_version = &server_major_version; + gpd2.out.server_minor_version = &server_minor_version; status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &gpd2); torture_assert_ntstatus_ok(tctx, status, "GetPrinterDriver2 failed"); @@ -301,6 +317,7 @@ static bool test_EnumForms(struct torture_context *tctx, NTSTATUS status; struct spoolss_EnumForms ef; DATA_BLOB blob = data_blob_talloc_zero(tctx, initial_blob_size); + uint32_t needed; torture_comment(tctx, "Testing EnumForms\n"); @@ -308,14 +325,15 @@ static bool test_EnumForms(struct torture_context *tctx, ef.in.level = 1; ef.in.buffer = (initial_blob_size == 0)?NULL:&blob; ef.in.offered = initial_blob_size; + ef.out.needed = &needed; status = dcerpc_spoolss_EnumForms(p, tctx, &ef); torture_assert_ntstatus_ok(tctx, status, "EnumForms failed"); if (W_ERROR_EQUAL(ef.out.result, WERR_INSUFFICIENT_BUFFER)) { - blob = data_blob_talloc_zero(tctx, ef.out.needed); + blob = data_blob_talloc_zero(tctx, needed); ef.in.buffer = &blob; - ef.in.offered = ef.out.needed; + ef.in.offered = needed; status = dcerpc_spoolss_EnumForms(p, tctx, &ef); torture_assert_ntstatus_ok(tctx, status, "EnumForms failed"); } @@ -339,14 +357,17 @@ static bool test_EnumPrinterKey(struct torture_context *tctx, epk.in.handle = handle; epk.in.key_name = talloc_strdup(tctx, key); - epk.in.needed = needed; + epk.in.key_buffer_size = 0; + epk.out.needed = &needed; + epk.out.key_buffer = talloc_array(tctx, uint16_t, 0); status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk); torture_assert_ntstatus_ok(tctx, status, "EnumPrinterKey failed"); if (W_ERROR_EQUAL(epk.out.result, WERR_MORE_DATA)) { - epk.in.needed = epk.out.needed; + epk.in.key_buffer_size = needed; + epk.out.key_buffer = talloc_array(tctx, uint16_t, needed/2); status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk); torture_assert_ntstatus_ok(tctx, status, "EnumPrinterKey failed"); @@ -355,7 +376,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx, torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed"); convert_string_talloc_convenience(ctx, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, - CH_UNIX, epk.out.key_buffer, epk.out.needed, + CH_UNIX, epk.out.key_buffer, *epk.out.needed, (void**)&ctx->printer_keys); return true; @@ -370,17 +391,23 @@ static bool test_EnumPrinterDataEx(struct torture_context *tctx, { NTSTATUS status; struct spoolss_EnumPrinterDataEx epde; + uint32_t needed; + uint32_t count; torture_comment(tctx, "Testing EnumPrinterDataEx(%s)\n", key); epde.in.handle = handle; epde.in.key_name = talloc_strdup(tctx, key); epde.in.offered = 0; + epde.out.needed = &needed; + epde.out.count = &count; + epde.out.buffer = talloc_array(tctx, uint8_t, 0); status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &epde); torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed."); if (W_ERROR_EQUAL(epde.out.result, WERR_MORE_DATA)) { - epde.in.offered = epde.out.needed; + epde.in.offered = needed; + epde.out.buffer = talloc_array(tctx, uint8_t, needed); status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &epde); torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed."); |