Skip to content

Commit

Permalink
Merge pull request #3721 from kinvolk/rata/nsfixes-backport
Browse files Browse the repository at this point in the history
[1.1] nsexec: Check for errors in write_log()
  • Loading branch information
AkihiroSuda committed Feb 10, 2023
2 parents 3775df9 + f6e2cd3 commit c6781d1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions libcontainer/nsenter/nsexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@ static void write_log(int level, const char *format, ...)

message = escape_json_string(message);

if (current_stage == STAGE_SETUP)
if (current_stage == STAGE_SETUP) {
stage = strdup("nsexec");
else
if (stage == NULL)
goto out;
} else {
ret = asprintf(&stage, "nsexec-%d", current_stage);
if (ret < 0) {
stage = NULL;
goto out;
if (ret < 0) {
stage = NULL;
goto out;
}
}

ret = asprintf(&json, "{\"level\":\"%s\", \"msg\": \"%s[%d]: %s\"}\n",
level_str[level], stage, getpid(), message);
if (ret < 0) {
Expand Down

0 comments on commit c6781d1

Please sign in to comment.