View | Details | Raw Unified | Return to bug 249041 | Differences between
and this patch

Collapse All | Expand All

(-)b/sysutils/apcupsd/Makefile (-1 / +1 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	apcupsd
4
PORTNAME=	apcupsd
5
PORTVERSION=	3.14.14
5
PORTVERSION=	3.14.14
6
PORTREVISION=	3
6
PORTREVISION=	4
7
CATEGORIES=	sysutils
7
CATEGORIES=	sysutils
8
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}%20-%20Stable/${PORTVERSION}
8
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}%20-%20Stable/${PORTVERSION}
9
9
(-)b/sysutils/apcupsd/files/patch-include_HidUps.h (+10 lines)
Added Link Here
1
--- include/HidUps.h.orig	2015-02-08 18:00:05 UTC
2
+++ include/HidUps.h
3
@@ -107,6 +107,7 @@ class HidUps (private)
4
    /* Fetch a descriptor from an interface (as opposed to from the device) */
5
    int GetIntfDescr(
6
       unsigned char type, unsigned char index, void *buf, int size);
7
+   int GetIntfDescrLength(unsigned char index);
8
 
9
    bool init_device(struct usb_device *dev, const char *serno);
10
 
(-)b/sysutils/apcupsd/files/patch-src_libusbhid_HidUps.cpp (-1 / +41 lines)
Added Link Here
0
- 
1
--- src/libusbhid/HidUps.cpp.orig	2015-02-08 18:00:05 UTC
2
+++ src/libusbhid/HidUps.cpp
3
@@ -244,6 +244,26 @@ int HidUps::GetIntfDescr(
4
                          (type << 8) + index, 0, (char*)buf, size, 1000);
5
 }
6
 
7
+/* Get the interface descriptor's length */
8
+int HidUps::GetIntfDescrLength(unsigned char index)
9
+{
10
+   /* usb_hid_descriptor  */
11
+   char buf[9];
12
+   memset(buf, 0, sizeof(buf));
13
+   int ret = usb_control_msg(_fd, USB_ENDPOINT_IN | USB_RECIP_INTERFACE,
14
+                            USB_REQ_GET_DESCRIPTOR,
15
+                            (USB_DT_HID << 8) + index, 0, (char*)buf, sizeof(buf), 1000);
16
+   
17
+   int len = MAX_SANE_DESCRIPTOR_LEN;
18
+   if (ret >= 0) {
19
+      /* wDescriptorLength */
20
+      int desclen = buf[7] | (buf[8] << 8);
21
+      if (desclen > 0)
22
+         len = desclen;
23
+   }
24
+   return len;
25
+}
26
+
27
 /*
28
  * Fetch the report descriptor from the device given an _fd for the
29
  * device's control endpoint. Descriptor length is written to the
30
@@ -255,8 +275,9 @@ unsigned char *HidUps::FetchReportDescr(int *rlen)
31
    unsigned char *ptr;
32
    int rdesclen;
33
 
34
-   ptr = (unsigned char*)malloc(MAX_SANE_DESCRIPTOR_LEN);
35
-   rdesclen = GetIntfDescr(USB_DT_REPORT, 0, ptr, MAX_SANE_DESCRIPTOR_LEN);
36
+   int desclen = GetIntfDescrLength(0);
37
+   ptr = (unsigned char*)malloc(desclen);
38
+   rdesclen = GetIntfDescr(USB_DT_REPORT, 0, ptr, desclen);
39
    if (rdesclen <= 0) {
40
       Dmsg(100, "Unable to get REPORT descriptor (%d).\n", rdesclen);
41
       free(ptr);

Return to bug 249041