[Nut-upsdev] newhidups with APC Smart-UPS - workaround!

Кузьменко Алексей Васильевич kuzmenko at pikinvest.ru
Wed Oct 18 16:37:22 UTC 2006


Hi.

I had a problem recently with %subj, and I've solved it.
Sent a letter with solution to maintainers, but it seems like I've lost it somewhere.
May be just simply forgot to write it.. But anyway.

I've noticed that I'm not the only one who had it. So I post the workaround.

The problem is similar to the one mentioned in letter with alike subject at Oct. 5.
When the UPS (Smart-UPS 2200 in my case) switches to battery, upsmon crashes instantly.
It's last words usually "ups.status = !chrg", and "bt" doesn't tell anything easily understandable.

It was caused by a bug(?) in libusb - it disregards the buffer size parameter when you get UPS data, and when switching to battery, UPS fires a salvo of 15, IIRC, events, and the buffer holds 10. Instant segfault!

The quick-and-dirty (but it hasn't failed me yet for 3 months in several installations) patch is below:

--- nut-2.0.4/drivers/newhidups.c.orig  2006-08-09 11:35:32.000000000 +0400
+++ nut-2.0.4/drivers/newhidups.c       2006-08-09 11:35:44.000000000 +0400
@@ -452,7 +452,7 @@
        hid_info_t *item;
        char *nutvalue;
        int retcode, evtCount = 0;
-       HIDItem *eventsList[10];
+       HIDItem *eventsList[30];

        upsdebugx(1, "upsdrv_updateinfo...");





More information about the Nut-upsdev mailing list