-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
Fix segfault in NUT clients with empty host/device name components #2053
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
…ion to return NULL if input was NULL (and log it) [networkupstools#2052] Signed-off-by: Jim Klimov <[email protected]>
… inputs [networkupstools#2052] Signed-off-by: Jim Klimov <[email protected]>
Signed-off-by: Jim Klimov <[email protected]>
499cedd
to
048876f
Compare
…y upsname and/or hostname[:port] parts, to report problems as such [networkupstools#2052] Signed-off-by: Jim Klimov <[email protected]>
Testing:
No more this report (from recent master) about trash going to networking name-resolver etc:
|
Weird... a handful of builds got segfaults during Gotta check if the |
… 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...
…was NULL (and log it) [networkupstools#2052] Signed-off-by: Jim Klimov <[email protected]>
✅ Build nut 2.8.0.749-master completed (commit 871f926afd by @jimklimov) |
Closes: #2052
The culprit was that in some libc implementations, calling
strdup(NULL)
causes a segfault, where suchNULL
can be returned bystrtok()
if there were no hits. Usingxstrdup()
introduced across NUT codebase specifically for safety checks like these turns it into a graceful failure that calling code can handle meaningfully.See also #677 for related concerns.