Blame SOURCES/0002-reader-make-PY_SSIZE_T_CLEAN.patch

fa62eb
From ab9f2797127b374665c37c06b02121f5dcf7d61c Mon Sep 17 00:00:00 2001
fa62eb
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
fa62eb
Date: Thu, 12 Nov 2020 16:55:56 +0100
fa62eb
Subject: [PATCH 2/2] reader: make PY_SSIZE_T_CLEAN
fa62eb
fa62eb
---
fa62eb
 systemd/_reader.c | 15 +++++++++++++--
fa62eb
 1 file changed, 13 insertions(+), 2 deletions(-)
fa62eb
fa62eb
diff --git a/systemd/_reader.c b/systemd/_reader.c
fa62eb
index 8de7f6a963..3b6a4d0bbc 100644
fa62eb
--- a/systemd/_reader.c
fa62eb
+++ b/systemd/_reader.c
fa62eb
@@ -18,7 +18,12 @@
fa62eb
   along with python-systemd; If not, see <http://www.gnu.org/licenses/>.
fa62eb
 ***/
fa62eb
 
fa62eb
+#define PY_SSIZE_T_CLEAN
fa62eb
+#pragma GCC diagnostic push
fa62eb
+#pragma GCC diagnostic ignored "-Wredundant-decls"
fa62eb
 #include <Python.h>
fa62eb
+#pragma GCC diagnostic pop
fa62eb
+
fa62eb
 #include <structmember.h>
fa62eb
 #include <datetime.h>
fa62eb
 #include <time.h>
fa62eb
@@ -710,11 +715,17 @@ PyDoc_STRVAR(Reader_add_match__doc__,
fa62eb
              "Match is a string of the form \"FIELD=value\".");
fa62eb
 static PyObject* Reader_add_match(Reader *self, PyObject *args, PyObject *keywds) {
fa62eb
         char *match;
fa62eb
-        int match_len, r;
fa62eb
+        Py_ssize_t match_len;
fa62eb
+        int r;
fa62eb
         if (!PyArg_ParseTuple(args, "s#:add_match", &match, &match_len))
fa62eb
                 return NULL;
fa62eb
 
fa62eb
-        r = sd_journal_add_match(self->j, match, match_len);
fa62eb
+        if (match_len > INT_MAX) {
fa62eb
+                set_error(-ENOBUFS, NULL, NULL);
fa62eb
+                return NULL;
fa62eb
+        }
fa62eb
+
fa62eb
+        r = sd_journal_add_match(self->j, match, (int) match_len);
fa62eb
         if (set_error(r, NULL, "Invalid match") < 0)
fa62eb
                 return NULL;
fa62eb