summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@tycho.nsa.gov>2008-10-22 15:49:45 -0400
committerEamon Walsh <ewalsh@tycho.nsa.gov>2008-10-22 15:49:45 -0400
commite3176b21a839e8bfa3ec4e56b1462839b7ea2d4c (patch)
tree174aa3921c8166d017e593ef0ce22f5d1a5b5175
parentb1b3db3ce10b08887e48c1bc608c65a50f8bd391 (diff)
Print the expected and actual buffer size when a list length calculated
from a size field is larger than the remaining buffer space. This error is unfortunately getting triggered by incorrect XML specs.
-rw-r--r--src/list.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/list.c b/src/list.c
index c4c8367..2633685 100644
--- a/src/list.c
+++ b/src/list.c
@@ -66,8 +66,9 @@ xpybList_init(xpybList *self, PyObject *args, PyObject *kw)
if (PyObject_AsReadBuffer(parent, (const void **)&data, &datalen) < 0)
return -1;
- if (length * size + offset > datalen) {
- PyErr_SetString(xpybExcept_base, "Protocol object buffer too short.");
+ if (size > 0 && length * size + offset > datalen) {
+ PyErr_Format(xpybExcept_base, "Protocol object buffer too short "
+ "(expected %zd got %zd).", length * size + offset, datalen);
return -1;
}