summaryrefslogtreecommitdiff
path: root/source3/python
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2002-11-04 22:29:03 +0000
committerMartin Pool <mbp@samba.org>2002-11-04 22:29:03 +0000
commitfeb15f90fe18ceb23491aae1695e6e4cf26a5f08 (patch)
tree2b0388339469ebccf572425e391ec3d0397b3b5c /source3/python
parent859850faf7bed5464f644df3aeedd40b9663be6a (diff)
downloadsamba-feb15f90fe18ceb23491aae1695e6e4cf26a5f08.tar.gz
samba-feb15f90fe18ceb23491aae1695e6e4cf26a5f08.tar.bz2
samba-feb15f90fe18ceb23491aae1695e6e4cf26a5f08.zip
pytdbpack_calc_reqd_len: Correct calculation of packed length of
string types (This used to be commit 30525aee33237f5b17e1067a96d09b7ee0a516a6)
Diffstat (limited to 'source3/python')
-rw-r--r--source3/python/py_tdbpack.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c
index 001b082f16..349085d64c 100644
--- a/source3/python/py_tdbpack.c
+++ b/source3/python/py_tdbpack.c
@@ -327,13 +327,12 @@ pytdbpack_calc_reqd_len(char *format_str,
if (!str_obj)
return -1;
- item_len = PyString_Size(str_obj);
- if (item_len == -1) {
+ if (!PyString_Check(str_obj) || ((item_len = PyString_Size(str_obj)) == -1)) {
pytdbpack_bad_type(ch, "String", str_obj);
return -1;
}
- len += item_len;
+ len += 1 + item_len;
}
else if (ch == 'B') {
/* length-preceded byte buffer: n bytes, plus a preceding
@@ -608,8 +607,12 @@ pytdbpack_pack_data(const char *format_str,
int size;
char *sval;
- size = PyString_GET_SIZE(val_obj);
- sval = PyString_AS_STRING(val_obj);
+ size = PySequence_Length(val_obj);
+ if (size < 0)
+ return NULL;
+ sval = PyString_AsString(val_obj);
+ if (!sval)
+ return NULL;
pack_bytes(size+1, sval, &packed); /* include nul */
}
else if (ch == 'B') {