summaryrefslogtreecommitdiff
path: root/Modules/_ctypes/callproc.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-04 15:05:40 -0800
committerSteve Dower <steve.dower@microsoft.com>2017-02-04 15:05:40 -0800
commitb2fa705fd3887c326e811c418469c784353027f4 (patch)
treeb3428f73de91453edbfd4df1a5d4a212d182eb44 /Modules/_ctypes/callproc.c
parent134e58fd3aaa2e91390041e143f3f0a21a60142b (diff)
parentb53654b6dbfce8318a7d4d1cdaddca7a7fec194b (diff)
downloadcpython-b2fa705fd3887c326e811c418469c784353027f4.tar.gz
Issue #29392: Prevent crash when passing invalid arguments into msvcrt module.
Diffstat (limited to 'Modules/_ctypes/callproc.c')
-rw-r--r--Modules/_ctypes/callproc.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index abd3bc995d..7d542fb50d 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -382,7 +382,7 @@ static void SetException(DWORD code, EXCEPTION_RECORD *pr)
whose operation is not allowed in the current
machine mode. */
PyErr_SetString(PyExc_OSError,
- "exception: priviledged instruction");
+ "exception: privileged instruction");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
@@ -474,7 +474,6 @@ PyCArg_repr(PyCArgObject *self)
self->tag, self->value.l);
break;
-#ifdef HAVE_LONG_LONG
case 'q':
case 'Q':
sprintf(buffer,
@@ -485,7 +484,6 @@ PyCArg_repr(PyCArgObject *self)
#endif
self->tag, self->value.q);
break;
-#endif
case 'd':
sprintf(buffer, "<cparam '%c' (%f)>",
self->tag, self->value.d);
@@ -593,9 +591,7 @@ union result {
short h;
int i;
long l;
-#ifdef HAVE_LONG_LONG
- PY_LONG_LONG q;
-#endif
+ long long q;
long double D;
double d;
float f;
@@ -930,7 +926,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker)
* Raise a new exception 'exc_class', adding additional text to the original
* exception string.
*/
-void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...)
+void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
{
va_list vargs;
PyObject *tp, *v, *tb, *s, *cls_str, *msg_str;
@@ -1203,7 +1199,7 @@ _parse_voidp(PyObject *obj, void **address)
#ifdef MS_WIN32
-static char format_error_doc[] =
+static const char format_error_doc[] =
"FormatError([integer]) -> string\n\
\n\
Convert a win32 error code into a string. If the error code is not\n\
@@ -1227,7 +1223,7 @@ static PyObject *format_error(PyObject *self, PyObject *args)
return result;
}
-static char load_library_doc[] =
+static const char load_library_doc[] =
"LoadLibrary(name) -> handle\n\
\n\
Load an executable (usually a DLL), and return a handle to it.\n\
@@ -1256,7 +1252,7 @@ static PyObject *load_library(PyObject *self, PyObject *args)
#endif
}
-static char free_library_doc[] =
+static const char free_library_doc[] =
"FreeLibrary(handle) -> void\n\
\n\
Free the handle of an executable previously loaded by LoadLibrary.\n";
@@ -1271,7 +1267,7 @@ static PyObject *free_library(PyObject *self, PyObject *args)
return Py_None;
}
-static char copy_com_pointer_doc[] =
+static const char copy_com_pointer_doc[] =
"CopyComPointer(src, dst) -> HRESULT value\n";
static PyObject *
@@ -1309,7 +1305,7 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args)
PyObject *name, *name2;
char *name_str;
void * handle;
-#ifdef RTLD_LOCAL
+#if HAVE_DECL_RTLD_LOCAL
int mode = RTLD_NOW | RTLD_LOCAL;
#else
/* cygwin doesn't define RTLD_LOCAL */
@@ -1441,7 +1437,7 @@ call_cdeclfunction(PyObject *self, PyObject *args)
/*****************************************************************
* functions
*/
-static char sizeof_doc[] =
+static const char sizeof_doc[] =
"sizeof(C type) -> integer\n"
"sizeof(C instance) -> integer\n"
"Return the size in bytes of a C instance";
@@ -1462,7 +1458,7 @@ sizeof_func(PyObject *self, PyObject *obj)
return NULL;
}
-static char alignment_doc[] =
+static const char alignment_doc[] =
"alignment(C type) -> integer\n"
"alignment(C instance) -> integer\n"
"Return the alignment requirements of a C instance";
@@ -1485,7 +1481,7 @@ align_func(PyObject *self, PyObject *obj)
return NULL;
}
-static char byref_doc[] =
+static const char byref_doc[] =
"byref(C instance[, offset=0]) -> byref-object\n"
"Return a pointer lookalike to a C instance, only usable\n"
"as function argument";
@@ -1529,7 +1525,7 @@ byref(PyObject *self, PyObject *args)
return (PyObject *)parg;
}
-static char addressof_doc[] =
+static const char addressof_doc[] =
"addressof(C instance) -> integer\n"
"Return the address of the C instance internal buffer";