summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/cjkcodecs')
-rw-r--r--Modules/cjkcodecs/clinic/multibytecodec.c.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/Modules/cjkcodecs/clinic/multibytecodec.c.h b/Modules/cjkcodecs/clinic/multibytecodec.c.h
index fec2239..305ade1 100644
--- a/Modules/cjkcodecs/clinic/multibytecodec.c.h
+++ b/Modules/cjkcodecs/clinic/multibytecodec.c.h
@@ -73,10 +73,15 @@ _multibytecodec_MultibyteCodec_encode(MultibyteCodecObject *self, PyObject *cons
errors = NULL;
}
else if (PyUnicode_Check(args[1])) {
- errors = PyUnicode_AsUTF8(args[1]);
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
if (errors == NULL) {
goto exit;
}
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
}
else {
_PyArg_BadArgument("encode", "argument 'errors'", "str or None", args[1]);
@@ -156,10 +161,15 @@ _multibytecodec_MultibyteCodec_decode(MultibyteCodecObject *self, PyObject *cons
errors = NULL;
}
else if (PyUnicode_Check(args[1])) {
- errors = PyUnicode_AsUTF8(args[1]);
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
if (errors == NULL) {
goto exit;
}
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
}
else {
_PyArg_BadArgument("decode", "argument 'errors'", "str or None", args[1]);
@@ -672,4 +682,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
-/*[clinic end generated code: output=b35a5c3797e0e54a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=219a363662d2fbff input=a9049054013a1b77]*/