summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2002-11-04 23:08:53 +0000
committerMartin Pool <mbp@samba.org>2002-11-04 23:08:53 +0000
commit3f9dac69487fc046b1bcc1730b3c22128311ad8c (patch)
tree36ad6c8c9f50cb8bd71a3b212103708d0eeb7801
parent0011607acafcafa39e2657c6d13d2cd0d038c8a4 (diff)
downloadsamba-3f9dac69487fc046b1bcc1730b3c22128311ad8c.tar.gz
samba-3f9dac69487fc046b1bcc1730b3c22128311ad8c.tar.bz2
samba-3f9dac69487fc046b1bcc1730b3c22128311ad8c.zip
pytdbpack_pack_data: Allow 'd' and 'w' formats to take either Integer
or Long arguments. (This used to be commit 2085595565b99295d04a6663aad1ccac5bc1b657)
-rw-r--r--source3/python/py_tdbpack.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c
index 526e187f75..446a2e5480 100644
--- a/source3/python/py_tdbpack.c
+++ b/source3/python/py_tdbpack.c
@@ -588,14 +588,32 @@ pytdbpack_pack_data(const char *format_str,
return NULL;
if (ch == 'w') {
- unsigned long val_long = PyInt_AsLong(val_obj);
+ unsigned long val_long;
+ PyObject *long_obj;
+
+ if (!(long_obj = PyNumber_Long(val_obj))) {
+ pytdbpack_bad_type(ch, "Long", val_obj);
+ return NULL;
+ }
+
+ val_long = PyLong_AsUnsignedLong(long_obj);
(packed)[0] = val_long & 0xff;
(packed)[1] = (val_long >> 8) & 0xff;
(packed) += 2;
+ Py_DECREF(long_obj);
}
else if (ch == 'd') {
/* 4-byte LE number */
- pack_uint32(PyInt_AsLong(val_obj), &packed);
+ PyObject *long_obj;
+
+ if (!(long_obj = PyNumber_Long(val_obj))) {
+ pytdbpack_bad_type(ch, "Long", val_obj);
+ return NULL;
+ }
+
+ pack_uint32(PyLong_AsUnsignedLong(long_obj), &packed);
+
+ Py_DECREF(long_obj);
}
else if (ch == 'p') {
/* "Pointer" value -- in the subset of DCERPC used by Samba,