summaryrefslogtreecommitdiff
path: root/python/samba
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2016-09-13 05:51:42 +0200
committerAndreas Schneider <asn@cryptomilk.org>2016-10-26 11:20:19 +0200
commit9b842badcb0fcc4b8d95473c206c68a56211435e (patch)
treec9c3aedab6325c0454028ce55f57eaa1e788b5fd /python/samba
parent40175613519e7405a16e8f896dfdc2949430bc4b (diff)
downloadsamba-9b842badcb0fcc4b8d95473c206c68a56211435e.tar.gz
python:ndr: verify the object type ndr_print() and ndr_unpack()
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'python/samba')
-rw-r--r--python/samba/ndr.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/python/samba/ndr.py b/python/samba/ndr.py
index 39e4a482efb..7a8f54af192 100644
--- a/python/samba/ndr.py
+++ b/python/samba/ndr.py
@@ -42,9 +42,15 @@ def ndr_unpack(cls, data, allow_remaining=False):
:return: Unpacked object
"""
object = cls()
- object.__ndr_unpack__(data, allow_remaining=allow_remaining)
+ ndr_unpack = getattr(object, "__ndr_unpack__", None)
+ if ndr_unpack is None:
+ raise TypeError("%r is not a NDR object" % object)
+ ndr_unpack(data, allow_remaining=allow_remaining)
return object
def ndr_print(object):
- return object.__ndr_print__()
+ ndr_print = getattr(object, "__ndr_print__", None)
+ if ndr_print is None:
+ raise TypeError("%r is not a NDR object" % object)
+ return ndr_print()