summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorXiang Zhang <angwerzx@126.com>2017-03-06 09:17:05 (GMT)
committerGitHub <noreply@github.com>2017-03-06 09:17:05 (GMT)
commitb76ad5121e2cfa89d6476d700cbcb65b7ffc39ac (patch)
treefd9ddcebff7e19fd07c62675dbdd5cceccd7963f /Objects/bytesobject.c
parent86aa269646fa73bbcbc26f45ed854359d04c1fde (diff)
downloadcpython-b76ad5121e2cfa89d6476d700cbcb65b7ffc39ac.zip
cpython-b76ad5121e2cfa89d6476d700cbcb65b7ffc39ac.tar.gz
cpython-b76ad5121e2cfa89d6476d700cbcb65b7ffc39ac.tar.bz2
bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. (GH-499)
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index a30ac0c..f0ddb95 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -619,11 +619,11 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
Py_ssize_t len;
char *pos;
- pos = strchr(fmt + 1, '%');
+ pos = (char *)memchr(fmt + 1, '%', fmtcnt);
if (pos != NULL)
len = pos - fmt;
else
- len = format_len - (fmt - format);
+ len = fmtcnt + 1;
assert(len != 0);
memcpy(res, fmt, len);