summaryrefslogtreecommitdiff
path: root/Modules/clinic/zlibmodule.c.h
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-04 15:05:50 -0800
committerSteve Dower <steve.dower@microsoft.com>2017-02-04 15:05:50 -0800
commit3b0e4320092ac0504b6670cafaf0301b908c91fc (patch)
treed3be1b6b844d61763bb366fa21ceed475e5703fd /Modules/clinic/zlibmodule.c.h
parentb2fa705fd3887c326e811c418469c784353027f4 (diff)
parentf687fbcd73c14dfcbe086eb5cd94b298f1e81e72 (diff)
downloadcpython-3b0e4320092ac0504b6670cafaf0301b908c91fc.tar.gz
Issue #29392: Prevent crash when passing invalid arguments into msvcrt module.
Diffstat (limited to 'Modules/clinic/zlibmodule.c.h')
-rw-r--r--Modules/clinic/zlibmodule.c.h52
1 files changed, 34 insertions, 18 deletions
diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h
index fda392a9cd..a9089ca7bb 100644
--- a/Modules/clinic/zlibmodule.c.h
+++ b/Modules/clinic/zlibmodule.c.h
@@ -28,7 +28,7 @@ zlib_compress(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwn
Py_buffer data = {NULL, NULL};
int level = Z_DEFAULT_COMPRESSION;
- if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
&data, &level)) {
goto exit;
}
@@ -73,7 +73,7 @@ zlib_decompress(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *k
int wbits = MAX_WBITS;
Py_ssize_t bufsize = DEF_BUF_SIZE;
- if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
&data, &wbits, ssize_t_converter, &bufsize)) {
goto exit;
}
@@ -138,7 +138,7 @@ zlib_compressobj(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *
int strategy = Z_DEFAULT_STRATEGY;
Py_buffer zdict = {NULL, NULL};
- if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
&level, &method, &wbits, &memLevel, &strategy, &zdict)) {
goto exit;
}
@@ -180,7 +180,7 @@ zlib_decompressobj(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject
int wbits = MAX_WBITS;
PyObject *zdict = NULL;
- if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
&wbits, &zdict)) {
goto exit;
}
@@ -262,7 +262,7 @@ zlib_Decompress_decompress(compobject *self, PyObject **args, Py_ssize_t nargs,
Py_buffer data = {NULL, NULL};
Py_ssize_t max_length = 0;
- if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
&data, ssize_t_converter, &max_length)) {
goto exit;
}
@@ -290,21 +290,25 @@ PyDoc_STRVAR(zlib_Compress_flush__doc__,
" can still be compressed.");
#define ZLIB_COMPRESS_FLUSH_METHODDEF \
- {"flush", (PyCFunction)zlib_Compress_flush, METH_VARARGS, zlib_Compress_flush__doc__},
+ {"flush", (PyCFunction)zlib_Compress_flush, METH_FASTCALL, zlib_Compress_flush__doc__},
static PyObject *
zlib_Compress_flush_impl(compobject *self, int mode);
static PyObject *
-zlib_Compress_flush(compobject *self, PyObject *args)
+zlib_Compress_flush(compobject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
int mode = Z_FINISH;
- if (!PyArg_ParseTuple(args, "|i:flush",
+ if (!_PyArg_ParseStack(args, nargs, "|i:flush",
&mode)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("flush", kwnames)) {
+ goto exit;
+ }
return_value = zlib_Compress_flush_impl(self, mode);
exit:
@@ -365,21 +369,25 @@ PyDoc_STRVAR(zlib_Decompress_flush__doc__,
" the initial size of the output buffer.");
#define ZLIB_DECOMPRESS_FLUSH_METHODDEF \
- {"flush", (PyCFunction)zlib_Decompress_flush, METH_VARARGS, zlib_Decompress_flush__doc__},
+ {"flush", (PyCFunction)zlib_Decompress_flush, METH_FASTCALL, zlib_Decompress_flush__doc__},
static PyObject *
zlib_Decompress_flush_impl(compobject *self, Py_ssize_t length);
static PyObject *
-zlib_Decompress_flush(compobject *self, PyObject *args)
+zlib_Decompress_flush(compobject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
Py_ssize_t length = DEF_BUF_SIZE;
- if (!PyArg_ParseTuple(args, "|O&:flush",
+ if (!_PyArg_ParseStack(args, nargs, "|O&:flush",
ssize_t_converter, &length)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("flush", kwnames)) {
+ goto exit;
+ }
return_value = zlib_Decompress_flush_impl(self, length);
exit:
@@ -398,22 +406,26 @@ PyDoc_STRVAR(zlib_adler32__doc__,
"The returned checksum is an integer.");
#define ZLIB_ADLER32_METHODDEF \
- {"adler32", (PyCFunction)zlib_adler32, METH_VARARGS, zlib_adler32__doc__},
+ {"adler32", (PyCFunction)zlib_adler32, METH_FASTCALL, zlib_adler32__doc__},
static PyObject *
zlib_adler32_impl(PyObject *module, Py_buffer *data, unsigned int value);
static PyObject *
-zlib_adler32(PyObject *module, PyObject *args)
+zlib_adler32(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
unsigned int value = 1;
- if (!PyArg_ParseTuple(args, "y*|I:adler32",
+ if (!_PyArg_ParseStack(args, nargs, "y*|I:adler32",
&data, &value)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("adler32", kwnames)) {
+ goto exit;
+ }
return_value = zlib_adler32_impl(module, &data, value);
exit:
@@ -437,22 +449,26 @@ PyDoc_STRVAR(zlib_crc32__doc__,
"The returned checksum is an integer.");
#define ZLIB_CRC32_METHODDEF \
- {"crc32", (PyCFunction)zlib_crc32, METH_VARARGS, zlib_crc32__doc__},
+ {"crc32", (PyCFunction)zlib_crc32, METH_FASTCALL, zlib_crc32__doc__},
static PyObject *
zlib_crc32_impl(PyObject *module, Py_buffer *data, unsigned int value);
static PyObject *
-zlib_crc32(PyObject *module, PyObject *args)
+zlib_crc32(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
Py_buffer data = {NULL, NULL};
unsigned int value = 0;
- if (!PyArg_ParseTuple(args, "y*|I:crc32",
+ if (!_PyArg_ParseStack(args, nargs, "y*|I:crc32",
&data, &value)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("crc32", kwnames)) {
+ goto exit;
+ }
return_value = zlib_crc32_impl(module, &data, value);
exit:
@@ -467,4 +483,4 @@ exit:
#ifndef ZLIB_COMPRESS_COPY_METHODDEF
#define ZLIB_COMPRESS_COPY_METHODDEF
#endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */
-/*[clinic end generated code: output=3a4e2bfe750423a3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=fa1b5f4a6208c342 input=a9049054013a1b77]*/