1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
Commit Graph

425 Commits

Author SHA1 Message Date
Douglas Bagnall
ed11ce8f12 Python pidl: avoid segfault with "del obj->attr"
Deleting an attribute in Python (using the "del" statement) is (at
some stages along a winding path, for C objects) converted into
setting the attribute to NULL. Not None, actual NULL. The way we
handled this NULL was to dereference it. This changes the behaviour to
raising an AttributeError, which is more or less what Python does in
similar situations with builtin objects.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-05-10 01:43:15 +02:00
Andrew Bartlett
f6c79072ca pidl: Correct string handling to use talloc and be in common
The previous string handling assumed the python variables referenced
by PyString_AS_STRING had infinite life.  When they were re-used
the C structure started to point at unexpected things.

We now check correctly for Unicode in every case, and we always
duplicate the string with talloc_strdup()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2016-05-10 01:43:15 +02:00
Douglas Bagnall
59d530c0b6 ndr: Use ndr_steal to avoid long lists
When pulling complex structures like nt-acls, a long list of tokens may
be produced. By removing tokens along the way with ndr_token_steal,
future calls to retrieve from the token list are not as expensive.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-22 08:00:31 +01:00
Douglas Bagnall
9af628a488 ndr: avoid unnecessary searches of token list
When pulling complex structures like nt-acls, a long list of tokens
may be produced. This change means the token list won't be walked in the
buffers case if the switch value is not needed.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-22 08:00:31 +01:00
Andrew Bartlett
90bf114f63 pidl: Use a tmp_ctx helper variable
This is so we free the ndr_push_struct_blob() return value after
we make it into a string

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-08 01:58:26 +01:00
Andrew Bartlett
dffa2dbfab pidl: Use the $mem_ctx helper variable
This is already set to pytalloc_get_mem_ctx(py_obj)

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-08 01:58:26 +01:00
Andrew Bartlett
9e07f3a13b pidl: Fix our python reference handling
The new talloc.BaseObject allow us to hold a talloc context per
python object (there may be many referring to the same C object)
and the talloc context that the actual object pointer is under.

Another advantage is that talloc.BaseObject(), has less of
an ABI surface.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-08 01:58:26 +01:00
Andrew Bartlett
a2d49fa74f pidl: Change PyGetSetDef in generated python bindings to use C99 initialisers
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-01-18 04:42:21 +01:00
Andrew Bartlett
638c611796 pidl: Use PY_SSIZE_T_CLEAN
This changes the type used for # arguments to PyArg_ParseTupleAndKeywords

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
2016-01-07 23:33:10 +01:00
Thomas Nagy
2666d06f29 build:wafsamba: removed most import * statements
The 'import *' statements make it more difficult to reason about
the modules and tends to conceal bugs. These changes enable running
pyflakes against most of the build scripts.

Signed-off-by: Thomas Nagy <tnagy@waf.io>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Oct 28 12:52:17 CET 2015 on sn-devel-104
2015-10-28 12:52:17 +01:00
Stefan Metzmacher
e6fbeb8606 pidl/python: also add a ndr_PyLong_FromLongLong() for symnetric reasons
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11429

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-09-01 14:01:23 +02:00
Andrew Bartlett
d1416d65a3 pidl/python: Provide static inline helper function ndr_PyLong_FromUnsignedLongLong
This should isolate any coverity warnings on 64-bit platforms
(where LONG_MAX is larger than any possible 32 bit value) to
a single spot, or possibly eliminate it.

This is needed for the unsigned 64 bit case, and on 32 bit
systems, as PyInt_FromLong is limited to a signed "long" int.

The compiler should be able to eliminate many of these calls
with the embedded type knowlege.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11429

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-09-01 14:01:23 +02:00
Andrew Bartlett
c2f4e324d9 pidl/python: Calculate maximum integer values using a lookup table
This avoids a << of 64 bits in the unused end of the conditional expression.

This was flagged by Coverity and the fix was suggested by metze.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11429

Andrew Bartlett

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-09-01 14:01:23 +02:00
Andrew Bartlett
e3cf25bdc0 pidl: Assert that python arrays will not overflow the C array
We do not write network services in Python, so this is not a security issue, but would cause
a crash or other odd behaviour if the length was changed

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11430

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-08-24 23:46:22 +02:00
Andrew Bartlett
5206ccd002 pidl: Change PIDL to correctly use and validate python integer types
In particular, it is critical that we use unsigned integers of
sufficient size in python for unsigned C integers, and it is
critical that we check for overflow at both the python and C
level.

Otherwise, we may both represent and sort these incorrectly,
in particular when sorting attributeID values from DRSUAPI
which are represented as an signed enum in C and a uint32_t in IDL,
but which often has the high bit set (in schema extensions).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11429

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-08-24 23:46:22 +02:00
Günther Deschner
adbd6d3253 pidl: merge multiple 'genpad' implementations into one.
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Fri Jul 24 16:44:16 CEST 2015 on sn-devel-104
2015-07-24 16:44:16 +02:00
Stefan Metzmacher
9f62c4e47b pidl:Samba4/NDR/Parser: always initialize _mem_save_ pointers to NULL
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2015-07-07 14:05:28 +02:00
Stefan Metzmacher
856c9aa503 pidl:Samba3/ServerNDR: add pidl_reset() and pidl_return() helper functions
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2015-07-07 14:05:28 +02:00
Stefan Metzmacher
16952dc7a4 pidl:Samba3/ServerNDR: make CallWithStruct() more flexible
We now pass multiple callbacks $check, $cleanup, $return
down to AllocOutVar().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2015-07-07 14:05:28 +02:00
Stefan Metzmacher
b3de334938 pidl:Samba3/ServerNDR: simplify CallWithStruct()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2015-07-07 14:05:28 +02:00
Douglas Bagnall
bba177100c Treat uid_t, git_t as 64 bit in Pidl Python bindings
This follows their treatment in librpc/ndr/ndr_basic.c.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-By: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue Jul  7 07:19:49 CEST 2015 on sn-devel-104
2015-07-07 07:19:49 +02:00
Douglas Bagnall
8a3d548ee7 remove trailing whitespace in Pidl/Samba4/Python.pm
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-06-24 06:04:10 +02:00
Douglas Bagnall
3c9f7957c9 Treat unsigned 64 bit IDL values as unsigned long long in Python
This caused a compilation error on i386:

default/librpc/gen_ndr/py_server_id.c:216:75: error: overflow in implicit constant conversion [-Werror=overflow]
  PyModule_AddObject(m, "SERVERID_UNIQUE_ID_NOT_TO_VERIFY", PyInt_FromLong(0xFFFFFFFFFFFFFFFFULL));

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-06-24 06:04:10 +02:00
Stefan Metzmacher
cf7e1c7597 pidl:NDR/Parser: check [ref] pointers before pushing anything else
This was reported by Coverity as
CID 1288527:  Null pointer dereferences  (REVERSE_INULL)

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-06-12 17:08:20 +02:00
Stefan Metzmacher
3c97bfe9de pidl:NDR/Parser: protect for loops against $length being an expression instead of a scalar variable
This changes

for (value_cntr_1 = 0; value_cntr_1 < r->out.length?*r->out.length:0; value_cntr_1++) {

into:

for (value_cntr_1 = 0; value_cntr_1 < (r->out.length?*r->out.length:0); value_cntr_1++) {

it fixes a possible endless loop resulting in a crash.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-06-12 17:08:19 +02:00
Stefan Metzmacher
781cc3d50f pidl:Python: protect for loops against $length being an expression instead of a scalar variable
This changes

for (value_cntr_1 = 0; value_cntr_1 < r->out.length?*r->out.length:0; value_cntr_1++) {

into:

for (value_cntr_1 = 0; value_cntr_1 < (r->out.length?*r->out.length:0); value_cntr_1++) {

it fixes a possible endless loop resulting in a crash.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-06-12 17:08:19 +02:00
Stefan Metzmacher
ad7148fec6 pidl:Python: use discard_const() to pass a possible const pointer to talloc_unlink()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-06-12 17:08:19 +02:00
Stefan Metzmacher
d1278f081b pidl:Samba3/ServerNDR: normalize {RETURN_TYPE} by using mapTypeName()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri May 15 22:19:38 CEST 2015 on sn-devel-104
2015-05-15 22:19:38 +02:00
Günther Deschner
b14a6d3580 pidl/python: add prototypes into header section of generated c-files.
This stops emmiting hundreds of warnings when compiling with
-Wmissing-prototypes.

Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Wed Mar 25 20:45:01 CET 2015 on sn-devel-104
2015-03-25 20:45:01 +01:00
Jelmer Vernooij
e67130c606 Explicitly include util/debug.h from server stubs generated by pidl.
This is necessary since Server.pm generates calls to DEBUG().

Signed-Off-By: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Mar 24 02:40:00 CET 2015 on sn-devel-104
2015-03-24 02:40:00 +01:00
Günther Deschner
210f1e6a21 pidl: align s4 dcesrv template generation with coding standards.
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-03-13 23:58:09 +01:00
Günther Deschner
c686e34dc6 pidl: add --template3 option to generate s3 server stubs.
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-03-13 23:58:09 +01:00
Günther Deschner
87054a5355 pidl/python: support HRESULT errors in generated python bindings.
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-03-13 23:58:07 +01:00
Günther Deschner
9564a1f295 pidl: support HRESULT in pidl.
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-03-13 23:58:07 +01:00
Petr Viktorin
02980268e8 Remove use of the "staticforward" macro
This macro was used for compatibility with broken compilers.
Since Python 2.3, it is always defined as `static`, and only exists
"for source compatibility with old C extensions".

Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2015-01-22 10:51:07 +01:00
Guy Harris
3949ed67fc Clean up more whitespace.
Reviewed-By: Jelmer Vernooij <jelmer@samba.org>
Reviewed-By: Kamen Mazdrashki <kamenim@samba.org>
Signed-Off-By: Jelmer Vernooij <jelmer@samba.org>
2014-11-22 02:23:10 +01:00
Guy Harris
082f88709a pidl: White space cleanups in Conformance.pm and NDR.pm
Change-Id: Ibf106d023c50a7f3caf8f416e9927ac4a040f2c0
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10842
Signed-Off-By: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date(master): Wed Nov 19 05:06:33 CET 2014 on sn-devel-104
2014-11-19 05:06:33 +01:00
Matthieu Patou
4b09df8978 pidl-wireshark: SWITCH_TYPE is not always defined, SwitchType() will try to find a fallback
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Matthieu Patou <mat@matws.net>
Signed-off-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Oct 24 01:39:16 CEST 2014 on sn-devel-104
2014-10-24 01:39:16 +02:00
Matthieu Patou
93f262ee6d pidl-wireshark: generate ALIGN_TO_x_BYTES instructions if the element has the align_x flag
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-23 23:12:05 +02:00
Matthieu Patou
3f6ca430b0 pidl-wireshark: if the structure has the flag no_align then set also no_align in the dceprc_info structure
Some dissection function will try to do alignment if the no_align flag
is not set.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Matthieu Patou <mat@matws.net>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-10-23 23:12:05 +02:00
Matthieu Patou
f0a6043fb2 pidl-wireshark: handle 8 bits enum and change the signature of enum function to pass the exact type
Instead of passing a uint32 in all cases we pass the exact type

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Change-Id: Ib79f1fa56d5aeb30c6e57eea8f0a48db60f6484d
Signed-off-by: Matthieu Patou <mat@matws.net>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-10-23 23:12:05 +02:00
Matthieu Patou
49e0dc7ad0 pidl-wireshark: add definition for IPV4/IPV6 types
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-23 23:12:05 +02:00
Matthieu Patou
725500fc28 pidl-wireshark: adapt to the new comments in the headers of wireshark dissectors
Change-Id: I4fc398c4d50230d1f0a083827493c1b193c045b9

Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-23 23:12:05 +02:00
Matthieu Patou
fa331f64d1 pidl-wireshark: insure that we have an entire match for the variable name
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Oct 10 00:32:40 CEST 2014 on sn-devel-104
2014-10-10 00:32:40 +02:00
Matthieu Patou
5d0d45c9a7 pidl-wireshark: generate an error for the new Pipe type in typedef
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Matthieu Patou <mat@matws.net>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 22:06:47 +02:00
Matthieu Patou
87fb54b77f pidl-wireshark: add the type dom_sid28 and call ad-hoc dissector
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 22:06:47 +02:00
Matthieu Patou
755bc4ed29 pidl-wireshark: add a function to change the type of a hf_field
We can use this to change the type FT_BYTE when we realize that the
object dissected is an array of bytes

Change-Id: I2d09c557fd050d0c279b8fff0a27db53403366ca
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 22:06:47 +02:00
Matthieu Patou
7e5048d28e pidl-wireshark: cosmetic reformat
Change-Id: I86a0d4f13575e5ef7c6968b93ce126e5df981873
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 22:06:47 +02:00
Matthieu Patou
343db5326b pidl-wireshark: Handle the case when the DATA_TYPE is not a simple type
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Change-Id: If78f241333c1372c60c7d00211c1e6aeb22c9719
Signed-off-by: Matthieu Patou <mat@matws.net>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 22:06:46 +02:00
Matthieu Patou
5740a06b32 pidl: Improve string delection in function ContainsString
Change-Id: I037e8b5f54fca8b512fd14edbefa34e59cb7f953
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-10-09 22:06:46 +02:00