diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-09-15 02:35:15 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-09-15 02:35:15 (GMT) |
commit | 0891ac017dd02f9c592c40940dff6b050523be00 (patch) | |
tree | c923b2083e61dfea689d38e7528a7e9936a5d9c1 /Modules | |
parent | 1048aa933f096c33738f5088c7362a00e2c5b85c (diff) | |
download | cpython-0891ac017dd02f9c592c40940dff6b050523be00.zip cpython-0891ac017dd02f9c592c40940dff6b050523be00.tar.gz cpython-0891ac017dd02f9c592c40940dff6b050523be00.tar.bz2 |
The 'p' (Pascal string) pack code acts unreasonably when the string size
and count exceed 255. Changed to preserve as much of the string as
possible (instead of count%256 characters).
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/structmodule.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Modules/structmodule.c b/Modules/structmodule.c index 46aa75b..61436f9 100644 --- a/Modules/structmodule.c +++ b/Modules/structmodule.c @@ -1360,6 +1360,8 @@ struct_pack(PyObject *self, PyObject *args) if (n < num) /* no real need, just to be nice */ memset(res+1+n, '\0', num-n); + if (n > 255) + n = 255; *res++ = n; /* store the length byte */ res += num; break; |