1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-14 19:24:43 +03:00
Joseph Sutton 346844b730 librpc: Change type of ‘u16string’ from ‘const uint16_t *’ to ‘const unsigned char *’
A u16string is supposed to contain UTF‐16 code units, but
ndr_pull_u16string() and ndr_push_u16string() fail to correctly ensure
this on big‐endian systems. Code that relies on the u16string array
containing correct values will then fail.

Fix ndr_pull_u16string() and ndr_push_u16string() to work on big‐endian
systems, ensuring that other code can use these strings without having
to worry about first encoding them to little‐endian.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-12-21 23:48:46 +00:00

75 lines
2.8 KiB
C

/*
Unix SMB/CIFS implementation.
Python interface to DCE/RPC library - utility functions.
Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
Copyright (C) 2010 Andrew Tridgell <tridge@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __PYRPC_UTIL_H__
#define __PYRPC_UTIL_H__
#include "librpc/rpc/pyrpc.h"
#define PyErr_FromNdrError(err) Py_BuildValue("(is)", err, ndr_map_error2string(err))
#define PyErr_SetNdrError(err) \
PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNdrError(err))
void PyErr_SetDCERPCStatus(struct dcerpc_pipe *p, NTSTATUS status);
typedef NTSTATUS (*py_dcerpc_call_fn) (struct dcerpc_binding_handle *, TALLOC_CTX *, void *);
typedef bool (*py_data_pack_fn) (PyObject *args, PyObject *kwargs, void *r);
typedef PyObject *(*py_data_unpack_fn) (void *r);
struct PyNdrRpcMethodDef {
const char *name;
const char *doc;
py_dcerpc_call_fn call;
py_data_pack_fn pack_in_data;
py_data_unpack_fn unpack_out_data;
uint32_t opnum;
const struct ndr_interface_table *table;
};
bool py_check_dcerpc_type(PyObject *obj, const char *module, const char *type_name);
bool PyInterface_AddNdrRpcMethods(PyTypeObject *object, const struct PyNdrRpcMethodDef *mds);
PyObject *py_dcerpc_interface_init_helper(PyTypeObject *type, PyObject *args, PyObject *kwargs, const struct ndr_interface_table *table);
struct ndr_syntax_id;
PyObject *py_dcerpc_syntax_init_helper(PyTypeObject *type, PyObject *args, PyObject *kwargs,
const struct ndr_syntax_id *syntax);
PyObject *py_return_ndr_struct(const char *module_name, const char *type_name,
TALLOC_CTX *r_ctx, void *r);
PyObject *PyString_FromStringOrNULL(const char *str);
PyObject *PyBytes_FromUtf16StringOrNULL(const unsigned char *str);
unsigned char *PyUtf16String_FromBytes(TALLOC_CTX *mem_ctx, PyObject *value);
PyObject *pyrpc_import_union(PyTypeObject *type, TALLOC_CTX *mem_ctx, int level,
const void *in, const char *typename);
void *pyrpc_export_union(PyTypeObject *type, TALLOC_CTX *mem_ctx, int level,
PyObject *in, const char *typename);
PyObject *py_dcerpc_ndr_pointer_deref(PyTypeObject *type, PyObject *obj);
PyObject *py_dcerpc_ndr_pointer_wrap(PyTypeObject *type, PyObject *obj);
#endif /* __PYRPC_UTIL_H__ */