Commit ab0eb45d authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

log: log_init -- Check for dup return code

Don't pass negative descriptor to install_service_fd

CID 996213 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)
7. negative_returns: "new_logfd" is passed to a parameter that cannot be negative.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ea5b03ce
...@@ -89,8 +89,13 @@ int log_init(const char *output) ...@@ -89,8 +89,13 @@ int log_init(const char *output)
pr_perror("Can't create log file %s", output); pr_perror("Can't create log file %s", output);
return -1; return -1;
} }
} else } else {
new_logfd = dup(DEFAULT_LOGFD); new_logfd = dup(DEFAULT_LOGFD);
if (new_logfd < 0) {
pr_perror("Can't dup log file");
return -1;
}
}
fd = install_service_fd(LOG_FD_OFF, new_logfd); fd = install_service_fd(LOG_FD_OFF, new_logfd);
close(new_logfd); close(new_logfd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment