File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 18
18
along with python-systemd; If not, see <http://www.gnu.org/licenses/>.
19
19
***/
20
20
21
+ #define PY_SSIZE_T_CLEAN
22
+ #pragma GCC diagnostic push
23
+ #pragma GCC diagnostic ignored "-Wredundant-decls"
21
24
#include <Python.h>
25
+ #pragma GCC diagnostic pop
26
+
22
27
#include <structmember.h>
23
28
#include <datetime.h>
24
29
#include <time.h>
@@ -710,11 +715,17 @@ PyDoc_STRVAR(Reader_add_match__doc__,
710
715
"Match is a string of the form \"FIELD=value\"." );
711
716
static PyObject * Reader_add_match (Reader * self , PyObject * args , PyObject * keywds ) {
712
717
char * match ;
713
- int match_len , r ;
718
+ Py_ssize_t match_len ;
719
+ int r ;
714
720
if (!PyArg_ParseTuple (args , "s#:add_match" , & match , & match_len ))
715
721
return NULL ;
716
722
717
- r = sd_journal_add_match (self -> j , match , match_len );
723
+ if (match_len > INT_MAX ) {
724
+ set_error (- ENOBUFS , NULL , NULL );
725
+ return NULL ;
726
+ }
727
+
728
+ r = sd_journal_add_match (self -> j , match , (int ) match_len );
718
729
if (set_error (r , NULL , "Invalid match" ) < 0 )
719
730
return NULL ;
720
731
You can’t perform that action at this time.
0 commit comments