[3.6] bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. (GH-504)


diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 5d48440..801711f 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -619,11 +619,11 @@
             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);