1976465 - [hplip] PY_SSIZE_T_CLEAN macro must be defined for '#' formats

require usbutils - needed by hp-diagnose_queues
This commit is contained in:
Zdenek Dohnal 2021-07-02 07:30:43 +02:00
parent 9c9af2ba19
commit 58b699ef49
2 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,76 @@
diff --git a/io/mudext/hpmudext.c b/io/mudext/hpmudext.c
index dca3e9d..dfcd22a 100644
--- a/io/mudext/hpmudext.c
+++ b/io/mudext/hpmudext.c
@@ -24,6 +24,8 @@ Authors: Don Welch, David Suffield, Naga Samrat Chowdary Narla
\*****************************************************************************/
+#define PY_SSIZE_T_CLEAN
+
#include <Python.h>
#include <stdarg.h>
#include "hpmud.h"
@@ -187,14 +189,22 @@ static PyObject *write_channel(PyObject *self, PyObject *args)
HPMUD_CHANNEL cd;
int timeout = 30;
char * buf;
- int buf_size = 0;
+ Py_ssize_t buf_size = 0;
+ int buf_size_asInt = 0;
int bytes_written = 0;
if (!PyArg_ParseTuple(args, "iis#|i", &dd, &cd, &buf, &buf_size, &timeout))
return NULL;
+ if (buf_size < INT_MIN)
+ buf_size_asInt = INT_MIN;
+ else if (buf_size > INT_MAX)
+ buf_size_asInt = INT_MAX;
+ else
+ buf_size_asInt = (int)buf_size;
+
Py_BEGIN_ALLOW_THREADS
- result = hpmud_write_channel(dd, cd, buf, buf_size, timeout, &bytes_written);
+ result = hpmud_write_channel(dd, cd, buf, buf_size_asInt, timeout, &bytes_written);
Py_END_ALLOW_THREADS
return Py_BuildValue("(ii)", result, bytes_written);
@@ -231,14 +241,22 @@ static PyObject *set_pml(PyObject *self, PyObject *args)
char * oid;
int type;
char * data;
- int data_size;
+ Py_ssize_t data_size = 0;
+ int data_size_asInt = 0;
int pml_result;
if (!PyArg_ParseTuple(args, "iisis#", &dd, &cd, &oid, &type, &data, &data_size))
return NULL;
+ if (data_size < INT_MIN)
+ data_size_asInt = INT_MIN;
+ else if (data_size > INT_MAX)
+ data_size_asInt = INT_MAX;
+ else
+ data_size_asInt = (int)data_size;
+
Py_BEGIN_ALLOW_THREADS
- result = hpmud_set_pml(dd, cd, oid, type, (void *)data, data_size, &pml_result);
+ result = hpmud_set_pml(dd, cd, oid, type, (void *)data, data_size_asInt, &pml_result);
Py_END_ALLOW_THREADS
return Py_BuildValue("(ii)", result, pml_result);
diff --git a/scan/scanext/scanext.c b/scan/scanext/scanext.c
index 1e6b514..597abd8 100755
--- a/scan/scanext/scanext.c
+++ b/scan/scanext/scanext.c
@@ -45,6 +45,8 @@ PERFORMANCE OF THIS SOFTWARE.
*******************************************************************/
+#define PY_SSIZE_T_CLEAN
+
/* _ScanDevice objects */
#include "Python.h"

View File

@ -7,7 +7,7 @@
Summary: HP Linux Imaging and Printing Project
Name: hplip
Version: 3.21.2
Release: 7%{?dist}
Release: 8%{?dist}
License: GPLv2+ and MIT and BSD and IJG and Public Domain and GPLv2+ with exceptions and ISC
Url: https://developers.hp.com/hp-linux-imaging-and-printing
@ -193,6 +193,9 @@ Patch62: hplip-systray-qt5.patch
# 1963114 - patch for hplip firmware load timeout fix
# reported upstream https://bugs.launchpad.net/hplip/+bug/1922404
Patch63: hplip-hpfirmware-timeout.patch
# 1976465 - [hplip] PY_SSIZE_T_CLEAN macro must be defined for '#' formats
# reported upstream https://bugs.launchpad.net/hplip/+bug/1933973
Patch64: hplip-pyssizet_clean.patch
%if 0%{?fedora} || 0%{?rhel} <= 8
# mention hplip-gui if you want to have GUI
@ -216,6 +219,8 @@ Requires: systemd
Requires: libsane-hpaio
# 1788643 - Fedora minimal does not ship tar by default
Requires: tar
# require usbutils, hp-diagnose_queues needs lsusb
Requires: usbutils
# require coreutils, because timeout binary is needed in post scriptlet,
# because hpcups-update-ppds script can freeze in certain situation and
@ -488,6 +493,8 @@ done
%patch62 -p1 -b .systray-qt5
# 1963114 - patch for hplip firmware load timeout fix
%patch63 -p1 -b .hpfirmware-timeout
# 1976465 - [hplip] PY_SSIZE_T_CLEAN macro must be defined for '#' formats
%patch64 -p1 -b .pyssizet_clean
%if 0%{?fedora} || 0%{?rhel} <= 8
# mention hplip-gui should be installed if you want GUI
@ -836,6 +843,10 @@ rm -f %{buildroot}%{_sysconfdir}/xdg/autostart/hplip-systray.desktop
%config(noreplace) %{_sysconfdir}/sane.d/dll.d/hpaio
%changelog
* Fri Jul 02 2021 Zdenek Dohnal <zdohnal@redhat.com> - 3.21.2-8
- 1976465 - [hplip] PY_SSIZE_T_CLEAN macro must be defined for '#' formats
- require usbutils - needed by hp-diagnose_queues
* Mon Jun 28 2021 Zdenek Dohnal <zdohnal@redhat.com> - 3.21.2-7
- sleep after utils.run() (related #1963114)