summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Dumpleton <Graham.Dumpleton@gmail.com>2022-05-25 16:36:12 +1000
committerGraham Dumpleton <Graham.Dumpleton@gmail.com>2022-05-25 16:36:12 +1000
commitb88a94ad80771522f85f78909131cc78fea36993 (patch)
treec82f6fb2c36f0c2be37187c19d1f87d3ed798362
parente82960b358c4697a100cf925d6819d437a1cf615 (diff)
downloadmod_wsgi-b88a94ad80771522f85f78909131cc78fea36993.tar.gz
Fix bug where daemon mode process could crash if invalid URL path was used.
-rw-r--r--docs/release-notes/version-4.9.2.rst3
-rw-r--r--src/server/mod_wsgi.c11
2 files changed, 14 insertions, 0 deletions
diff --git a/docs/release-notes/version-4.9.2.rst b/docs/release-notes/version-4.9.2.rst
index ff57683..2701dab 100644
--- a/docs/release-notes/version-4.9.2.rst
+++ b/docs/release-notes/version-4.9.2.rst
@@ -9,3 +9,6 @@ Version 4.9.2 of mod_wsgi can be obtained from:
Bugs Fixed
----------
+* When using ``mod_wsgi-express`` in daemon mode, and source code reloading
+ was enabled, an invalid URL path which contained a byte sequence which
+ could not be decoded as UTF-8 was causing a process crash.
diff --git a/src/server/mod_wsgi.c b/src/server/mod_wsgi.c
index 59aad90..0123472 100644
--- a/src/server/mod_wsgi.c
+++ b/src/server/mod_wsgi.c
@@ -3852,9 +3852,20 @@ static int wsgi_reload_required(apr_pool_t *pool, request_rec *r,
if (object) {
PyObject *args = NULL;
PyObject *result = NULL;
+#if PY_MAJOR_VERSION >= 3
+ PyObject *path = NULL;
+#endif
Py_INCREF(object);
+#if PY_MAJOR_VERSION >= 3
+ path = PyUnicode_Decode(resource, strlen(resource),
+ Py_FileSystemDefaultEncoding,
+ "surrogateescape");
+ args = Py_BuildValue("(O)", path);
+ Py_DECREF(path);
+#else
args = Py_BuildValue("(s)", resource);
+#endif
result = PyObject_CallObject(object, args);
Py_DECREF(args);
Py_DECREF(object);