You need to sign in or sign up before continuing.
Unverified Commit 2ca32216 authored by Alexander Færøy's avatar Alexander Færøy Committed by Alexander Færøy
Browse files

Split lines before logging in log_from_pipe().

This patch ensures that we work on lines using
tor_get_lines_from_handle() instead of a raw buffer possibly containing
multiple lines from get_string_from_pipe().

See: #21765
parent a28be68c
......@@ -5287,11 +5287,11 @@ static int
log_from_pipe(int fd, int severity, const char *executable,
int *child_status)
{
char buf[256];
smartlist_t *lines = NULL;
enum stream_status r;
for (;;) {
r = get_string_from_pipe(fd, buf, sizeof(buf) - 1);
lines = tor_get_lines_from_handle(fd, &r);
if (r == IO_STREAM_CLOSED) {
return 1;
......@@ -5302,13 +5302,20 @@ log_from_pipe(int fd, int severity, const char *executable,
}
tor_assert(r == IO_STREAM_OKAY);
tor_assert(lines != NULL);
/* Check if buf starts with SPAWN_ERROR_MESSAGE */
if (strcmpstart(buf, SPAWN_ERROR_MESSAGE) == 0) {
log_portfw_spawn_error_message(buf, executable, child_status);
} else {
log_fn(severity, LD_GENERAL, "Port forwarding helper says: %s", buf);
}
SMARTLIST_FOREACH_BEGIN(lines, char *, line) {
/* Check if line starts with SPAWN_ERROR_MESSAGE */
if (strcmpstart(line, SPAWN_ERROR_MESSAGE) == 0) {
log_portfw_spawn_error_message(line, executable, child_status);
} else {
log_fn(severity, LD_GENERAL, "Port forwarding helper says: %s", line);
}
tor_free(line);
} SMARTLIST_FOREACH_END(line);
smartlist_free(lines);
}
/* We should never get here */
......
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