Skip to content

Commit

Permalink
powerman: correct potential segfault
Browse files Browse the repository at this point in the history
Problem: In _process_setresult() if the plug name is not found
in the inputted arglist, it can result in a segfault.  This
can occur when power operations on dependent targets (e.g. the
parent of node needs to be powered on) have errors, leading to
an unexpected host having a "power result".

Check that arg is non-NULL before trying to dereference it.

Fixes #197
  • Loading branch information
chu11 committed Sep 9, 2024
1 parent ee88e78 commit 2dad0bb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/powerman/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ static bool _process_setresult(Device *dev, Action *act, ExecCtx *e)
arg->val = xstrdup(str);
}

if (result != RT_SUCCESS) {
if (arg && result != RT_SUCCESS) {
char strbuf[1024];
snprintf(strbuf, sizeof(strbuf), "%s", arg->val);
/* remove trailing carriage return or newline */
Expand Down

0 comments on commit 2dad0bb

Please sign in to comment.