aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2019-11-07 07:27:03 -0800
committerGitHub <noreply@github.com>2019-11-07 07:27:03 -0800
commit9f94e52e8d38092520a3bfb1bf1ef9cbb0836584 (patch)
treed951ff7c6f23a2dda60b047ae4069a97b6004bb4
parent[2.7] bpo-38730: Fix -Wstringop-truncation warnings. (GH-17075) (diff)
downloadcpython-9f94e52e8d38092520a3bfb1bf1ef9cbb0836584.tar.gz
cpython-9f94e52e8d38092520a3bfb1bf1ef9cbb0836584.tar.bz2
cpython-9f94e52e8d38092520a3bfb1bf1ef9cbb0836584.zip
bpo-38730: Remove usage of stpncpy as it's not supported on MSVC 2008. (GH-17081)
-rw-r--r--Objects/structseq.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 14b51688a6..82df926f28 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -252,7 +252,12 @@ structseq_repr(PyStructSequence *obj)
}
/* "typename(", limited to TYPE_MAXSIZE */
- pbuf = stpncpy(pbuf, typ->tp_name, TYPE_MAXSIZE);
+ len = strlen(typ->tp_name);
+ if (len > TYPE_MAXSIZE) {
+ len = TYPE_MAXSIZE;
+ }
+ pbuf = memcpy(pbuf, typ->tp_name, len);
+ pbuf += len;
*pbuf++ = '(';
for (i=0; i < VISIBLE_SIZE(obj); i++) {