Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing null values to upsc results in kernel segmentation fault #2052

Closed
desertwitch opened this issue Sep 14, 2023 · 4 comments · Fixed by #2053
Closed

passing null values to upsc results in kernel segmentation fault #2052

desertwitch opened this issue Sep 14, 2023 · 4 comments · Fixed by #2053
Labels
bug impacts-release-2.7.4 Issues reported against NUT release 2.7.4 (maybe vanilla or with minor packaging tweaks) impacts-release-2.8.0 Issues reported against NUT release 2.8.0 (maybe vanilla or with minor packaging tweaks) portability We want NUT to build and run everywhere possible
Milestone

Comments

@desertwitch
Copy link
Contributor

desertwitch commented Sep 14, 2023

when bash scripting with upsc it could happen that null variables are passed to upsc by mistake, reproducible with the terminal command upsc $UPS@$HOST for example - which would result in: upsc @ when those variables are in fact not set and/or null.

upsc @ currently results in a kernel segmentation fault on latest master, see:

root@Tower:~# upsc $UPS@$HOST
Segmentation fault
Sep 14 20:06:27 Tower kernel: upsc[28685]: segfault at 8 ip 000014a0bbce4236 sp 00007ffd21f42468 error 4 in libc-2.37.so[14a0bbc58000+169000] likely on CPU 1 (core 1, socket 0)
Sep 14 20:06:27 Tower kernel: Code: 00 00 66 90 66 0f ef c0 66 0f ef c9 66 0f ef d2 66 0f ef db 48 89 f8 48 89 f9 48 81 e1 ff 0f 00 00 48 81 f9 cf 0f 00 00 77 6a <f3> 0f 6f 20 66 0f 74 e0 66 0f d7 d4 85 d2 74 04 0f bc c2 c3 48 83

is there a way to recover from such an (easy to happen) mistake better than with a segmentation fault - perhaps such a malformation in the arguments could be caught before it would throw the kernel in distress?

OS: Slackware 15.0, NUT compiled from master

@jimklimov
Copy link
Member

jimklimov commented Sep 14, 2023 via email

@desertwitch
Copy link
Contributor Author

yes, compiled from today's state of master branch
indeed - seg fault - shouldn't raise github issues from the train ;-)

@jimklimov
Copy link
Member

Thanks! PR #2053 should solve this:

$ ./clients/upsc @
upscli_splitname: xstrdup failed
Error: invalid UPS definition.
Required format: upsname[@hostname[:port]]

jimklimov added a commit to jimklimov/nut that referenced this issue Sep 14, 2023
…ion to return NULL if input was NULL (and log it) [networkupstools#2052]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Sep 14, 2023
jimklimov added a commit to jimklimov/nut that referenced this issue Sep 14, 2023
@jimklimov jimklimov added bug portability We want NUT to build and run everywhere possible impacts-release-2.8.0 Issues reported against NUT release 2.8.0 (maybe vanilla or with minor packaging tweaks) impacts-release-2.7.4 Issues reported against NUT release 2.7.4 (maybe vanilla or with minor packaging tweaks) labels Sep 14, 2023
@jimklimov jimklimov added this to the 2.8.1 milestone Sep 14, 2023
jimklimov added a commit to jimklimov/nut that referenced this issue Sep 14, 2023
…y upsname and/or hostname[:port] parts, to report problems as such [networkupstools#2052]

Signed-off-by: Jim Klimov <[email protected]>
jimklimov added a commit to jimklimov/nut that referenced this issue Sep 16, 2023
… definition to return NULL if input was NULL (and log it) [networkupstools#2052]"

This reverts commit 05610d1.
Seems to cause segfaults on its own, maybe something relied on
older behavior (non-NULLs returned in case of bad inputs?)
To investigate separately later...
jimklimov added a commit to jimklimov/nut that referenced this issue Sep 16, 2023
@desertwitch
Copy link
Contributor Author

confirmed working on my system now - thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug impacts-release-2.7.4 Issues reported against NUT release 2.7.4 (maybe vanilla or with minor packaging tweaks) impacts-release-2.8.0 Issues reported against NUT release 2.8.0 (maybe vanilla or with minor packaging tweaks) portability We want NUT to build and run everywhere possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants