summaryrefslogtreecommitdiff
path: root/Modules/structmodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-15 02:35:15 +0000
committerTim Peters <tim.peters@gmail.com>2001-09-15 02:35:15 +0000
commit1ab395f44b18b11135ccbfc13a2cf1c7ad462471 (patch)
tree2854fbee383d936465f78207fec7243790657ae4 /Modules/structmodule.c
parent6fabbcf031a9f91edb0c8fb72a294fb3b3f7c2c5 (diff)
downloadcpython-1ab395f44b18b11135ccbfc13a2cf1c7ad462471.tar.gz
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/structmodule.c')
-rw-r--r--Modules/structmodule.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index 46aa75bd53..61436f92a8 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;