-
-
Notifications
You must be signed in to change notification settings - Fork 437
upsc segfaults (SIGSEGV) when querying remote upsd on FreeBSD 14.x with NUT 2.8.5 #3454
Copy link
Copy link
Open
Labels
FreeBSDissues related to FreeBSD and its derivatives (including pfSense)issues related to FreeBSD and its derivatives (including pfSense)SSL/NSSIssues and PRs about SSL, TLS and other crypto-related mattersIssues and PRs about SSL, TLS and other crypto-related mattersbugimpacts-release-2.8.5Issues reported against NUT release 2.8.5 (maybe vanilla or with minor packaging tweaks)Issues reported against NUT release 2.8.5 (maybe vanilla or with minor packaging tweaks)
Milestone
Metadata
Metadata
Assignees
Labels
FreeBSDissues related to FreeBSD and its derivatives (including pfSense)issues related to FreeBSD and its derivatives (including pfSense)SSL/NSSIssues and PRs about SSL, TLS and other crypto-related mattersIssues and PRs about SSL, TLS and other crypto-related mattersbugimpacts-release-2.8.5Issues reported against NUT release 2.8.5 (maybe vanilla or with minor packaging tweaks)Issues reported against NUT release 2.8.5 (maybe vanilla or with minor packaging tweaks)
Type
Fields
Give feedbackNo fields configured for issues without a type.
Environment
Affected: NUT 2.8.5_1 on FreeBSD 14.3-RELEASE-p12 (OPNsense 26.1)
Working: NUT 2.8.2_1 on FreeBSD 15.0-RELEASE-p5
UPS Server: Raspberry Pi running NUT 2.8.1 in netserver mode (Raspberry Pi OS)
UPS: CyberPower CP1500PFCLCDa (usbhid-ups driver)
Describe the bug
When running upsc on FreeBSD 14.3 with NUT 2.8.5 to query a remote upsd server, the process terminates with a segmentation fault (SIGSEGV, exit code 11) after successfully connecting and receiving data — but before writing any output. This means no UPS data is returned to stdout regardless of whether output is redirected to a file, pipe, or captured by a calling process such as PHP shell_exec().
The same query against the same remote server works correctly on FreeBSD 15.0 with NUT 2.8.2, suggesting a regression introduced between NUT 2.8.2 and 2.8.5.
To Reproduce
On a FreeBSD 14.3 system with NUT 2.8.5 installed, query a remote NUT server:
upsc upsname@192.168.x.x
Expected result:
battery.charge: 100
battery.runtime: 11425
ups.status: OL
... (full variable list)
Actual result:
Segmentation fault
With output redirected to a file:
upsc upsname@192.168.x.x > /tmp/output.txt
Segmentation fault
The file is empty — no output is written before the crash.
Verified exit code is 11 (SIGSEGV) via PHP exec():
phpexec('/usr/local/bin/upsc upsname@192.168.x.x', $output, $return_code);
// $return_code = 11, $output = []
Additional context
The remote server itself is functioning correctly — other clients on the network can query it without issue. The NUT protocol socket connection works perfectly when implemented directly in PHP using fsockopen() on port 3493, retrieving full UPS data without any crash. This confirms the remote server is healthy and the bug is specific to the upsc binary when querying remote hosts.
This bug was discovered while attempting to use upsc from within the OPNsense NUT plugin's PHP diagnostics controller. The workaround implemented was to bypass upsc entirely and communicate with the remote upsd directly via TCP socket using the NUT protocol.
Workaround
Connect directly to upsd via TCP socket on port 3493 using the NUT protocol instead of calling upsc. Example in PHP:
php$socket = fsockopen('192.168.x.x', 3493, $errno, $errstr, 5);
fwrite($socket, "LIST VAR upsname\n");
// read response...