From 4cb9ccd84125708613074c2371f9507755ad4115 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 5 Feb 2009 09:39:03 +0100 Subject: s4:lib/registry: fix c++ warnings metze --- source4/lib/registry/patchfile_preg.c | 14 +++++++------- source4/lib/registry/regf.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/lib/registry') diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c index 26b57e4f45..e9801bb425 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/regf.c b/source4/lib/registry/regf.c index 4cbcb09a10..fbb9cd9de9 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); -- cgit From e5a6eadd8214b56da34f733318a0fecaebbe5ef5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 5 Feb 2009 15:58:40 +0100 Subject: s4:pyregistry: fix compiler warnings metze --- source4/lib/registry/pyregistry.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'source4/lib/registry') diff --git a/source4/lib/registry/pyregistry.c b/source4/lib/registry/pyregistry.c index 166543b6fd..9ebd136081 100644 --- a/source4/lib/registry/pyregistry.c +++ b/source4/lib/registry/pyregistry.c @@ -18,29 +18,32 @@ */ #include "includes.h" +#include #include #include "libcli/util/pyerrors.h" #include "lib/registry/registry.h" #include "scripting/python/modules.h" /* for py_iconv_convenience() */ #include -#include +#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) py_talloc_get_type(obj, struct registry_context) +#define PyHiveKey_AsHiveKey(obj) py_talloc_get_type(obj, struct hive_key) + 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 +59,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 +73,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 +90,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 +102,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 +127,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 +169,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 +185,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 +197,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 +215,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; -- cgit From 2170a810ed16043c6292eb3e39437a8cf96a8be6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Feb 2009 12:10:23 +0100 Subject: s4:pyregistry: fix crash bugs introduced by e5a6eadd8214b56da34f733318a0fecaebbe5ef5 The registry api uses wild casts in the returned types, so we can't check the talloc name against the type used in the public api... metze --- source4/lib/registry/pyregistry.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/registry') diff --git a/source4/lib/registry/pyregistry.c b/source4/lib/registry/pyregistry.c index 9ebd136081..30becbb1bb 100644 --- a/source4/lib/registry/pyregistry.c +++ b/source4/lib/registry/pyregistry.c @@ -36,8 +36,9 @@ PyAPI_DATA(PyTypeObject) PyRegistry; PyAPI_DATA(PyTypeObject) PyHiveKey; /*#define PyRegistryKey_AsRegistryKey(obj) py_talloc_get_type(obj, struct registry_key)*/ -#define PyRegistry_AsRegistryContext(obj) py_talloc_get_type(obj, struct registry_context) -#define PyHiveKey_AsHiveKey(obj) py_talloc_get_type(obj, struct hive_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) { -- cgit