fix usb report reading (#698512)

This commit is contained in:
Michal Hlavinka 2011-04-21 16:22:46 +02:00
commit b548c7c26b
2 changed files with 36 additions and 1 deletions

28
nut-2.6.0-usbget.patch Normal file
View file

@ -0,0 +1,28 @@
Index: /trunk/drivers/libhid.c
===================================================================
--- trunk/drivers/libhid.c (revision 2719)
+++ trunk/drivers/libhid.c (revision 2893)
@@ -142,5 +142,4 @@
int id = pData->ReportID;
int r;
- unsigned char buf[SMALLBUF];
if (rbuf->ts[id] + age > time(NULL)) {
@@ -150,15 +149,12 @@
}
- r = comm_driver->get_report(udev, id, buf, sizeof(buf));
+ r = comm_driver->get_report(udev, id, rbuf->data[id], rbuf->len[id]);
if (r <= 0) {
return -1;
}
- /* broken report descriptors are common, so store whatever we can */
- memcpy(rbuf->data[id], buf, (r < rbuf->len[id]) ? r : rbuf->len[id]);
-
if (rbuf->len[id] != r) {
upsdebugx(2, "%s: expected %d bytes, but got %d instead", __func__, rbuf->len[id], r);
- upsdebug_hex(3, "Report[err]", buf, r);
+ upsdebug_hex(3, "Report[err]", rbuf->data[id], r);
} else {
upsdebug_hex(3, "Report[get]", rbuf->data[id], rbuf->len[id]);

View file

@ -14,7 +14,7 @@
Summary: Network UPS Tools
Name: nut
Version: 2.6.0
Release: 7%{?dist}
Release: 8%{?dist}
Group: Applications/System
License: GPLv2+
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -26,6 +26,9 @@ Source3: nut-client.tmpfiles
Patch0: nut-2.2.1-conf.patch
#for nut < 2.6.1
Patch1: nut-2.6.0-usbget.patch
Requires(pre): udev
Requires(post): fileutils chkconfig initscripts
Requires(postun): fileutils chkconfig initscripts
@ -110,6 +113,7 @@ necessary to develop NUT client applications.
%prep
%setup -q
%patch0 -p1 -b .conf
%patch1 -p1 -b .usbget
sed -i 's|=NUT-Monitor|=nut-monitor|' scripts/python/app/nut-monitor.desktop
sed -i "s|sys.argv\[0\]|'%{_datadir}/%{name}/nut-monitor/nut-monitor'|" scripts/python/app/NUT-Monitor
sed -i 's|LIBSSL_LDFLAGS|LIBSSL_LIBS|' lib/libupsclient-config.in
@ -361,6 +365,9 @@ rm -rf %{buildroot}
%{_libdir}/pkgconfig/libupsclient.pc
%changelog
* Thu Apr 21 2011 Michal Hlavinka <mhlavink@redhat.com> - 2.6.0-8
- fix usb report reading (#698512)
* Thu Apr 21 2011 Michal Hlavinka <mhlavink@redhat.com> - 2.6.0-7
- nut-hal should be obsoleted to prevent broken dependency in yum