Loading src/common/util.c +38 −53 Original line number Diff line number Diff line Loading @@ -3173,6 +3173,12 @@ get_string_from_pipe(FILE *stream, char *buf_out, size_t count) if (buf_out[len - 1] == '\n') { /* Remove the trailing newline */ buf_out[len - 1] = '\0'; } else { /* No newline; check whether we overflowed the buffer */ if (!feof(stream)) log_warn(LD_GENERAL, "Line from stream was truncated: %s", buf_out); /* TODO: What to do with this error? */ } return IO_STREAM_OKAY; Loading @@ -3192,42 +3198,22 @@ log_from_pipe(FILE *stream, int severity, const char *executable, int *child_status) { char buf[256]; enum stream_status r; for (;;) { char *retval; retval = fgets(buf, sizeof(buf), stream); r = get_string_from_pipe(stream, buf, sizeof(buf) - 1); if (NULL == retval) { if (feof(stream)) { /* Program has closed stream (probably it exited) */ /* TODO: check error */ if (r == IO_STREAM_CLOSED) { fclose(stream); return 1; } else { if (EAGAIN == errno) { /* Nothing more to read, try again next time */ } else if (r == IO_STREAM_EAGAIN) { return 0; } else { /* There was a problem, abandon this child process */ } else if (r == IO_STREAM_TERM) { fclose(stream); return -1; } } } else { /* We have some data, log it and keep asking for more */ size_t len; len = strlen(buf); if (buf[len - 1] == '\n') { /* Remove the trailing newline */ buf[len - 1] = '\0'; } else { /* No newline; check whether we overflowed the buffer */ if (!feof(stream)) log_warn(LD_GENERAL, "Line from port forwarding helper was truncated: %s", buf); /* TODO: What to do with this error? */ } tor_assert(r == IO_STREAM_OKAY); /* Check if buf starts with SPAWN_ERROR_MESSAGE */ if (strcmpstart(buf, SPAWN_ERROR_MESSAGE) == 0) { Loading @@ -3252,7 +3238,6 @@ log_from_pipe(FILE *stream, int severity, const char *executable, log_fn(severity, LD_GENERAL, "Port forwarding helper says: %s", buf); } } } /* We should never get here */ return -1; Loading src/or/transports.c +0 −2 Original line number Diff line number Diff line Loading @@ -157,8 +157,6 @@ configure_proxy(managed_proxy_t *mp) char stdout_buf[200]; while (1) { memset(stdout_buf, 0, sizeof(stdout_buf)); r = get_string_from_pipe(mp->stdout, stdout_buf, sizeof(stdout_buf) - 1); Loading Loading
src/common/util.c +38 −53 Original line number Diff line number Diff line Loading @@ -3173,6 +3173,12 @@ get_string_from_pipe(FILE *stream, char *buf_out, size_t count) if (buf_out[len - 1] == '\n') { /* Remove the trailing newline */ buf_out[len - 1] = '\0'; } else { /* No newline; check whether we overflowed the buffer */ if (!feof(stream)) log_warn(LD_GENERAL, "Line from stream was truncated: %s", buf_out); /* TODO: What to do with this error? */ } return IO_STREAM_OKAY; Loading @@ -3192,42 +3198,22 @@ log_from_pipe(FILE *stream, int severity, const char *executable, int *child_status) { char buf[256]; enum stream_status r; for (;;) { char *retval; retval = fgets(buf, sizeof(buf), stream); r = get_string_from_pipe(stream, buf, sizeof(buf) - 1); if (NULL == retval) { if (feof(stream)) { /* Program has closed stream (probably it exited) */ /* TODO: check error */ if (r == IO_STREAM_CLOSED) { fclose(stream); return 1; } else { if (EAGAIN == errno) { /* Nothing more to read, try again next time */ } else if (r == IO_STREAM_EAGAIN) { return 0; } else { /* There was a problem, abandon this child process */ } else if (r == IO_STREAM_TERM) { fclose(stream); return -1; } } } else { /* We have some data, log it and keep asking for more */ size_t len; len = strlen(buf); if (buf[len - 1] == '\n') { /* Remove the trailing newline */ buf[len - 1] = '\0'; } else { /* No newline; check whether we overflowed the buffer */ if (!feof(stream)) log_warn(LD_GENERAL, "Line from port forwarding helper was truncated: %s", buf); /* TODO: What to do with this error? */ } tor_assert(r == IO_STREAM_OKAY); /* Check if buf starts with SPAWN_ERROR_MESSAGE */ if (strcmpstart(buf, SPAWN_ERROR_MESSAGE) == 0) { Loading @@ -3252,7 +3238,6 @@ log_from_pipe(FILE *stream, int severity, const char *executable, log_fn(severity, LD_GENERAL, "Port forwarding helper says: %s", buf); } } } /* We should never get here */ return -1; Loading
src/or/transports.c +0 −2 Original line number Diff line number Diff line Loading @@ -157,8 +157,6 @@ configure_proxy(managed_proxy_t *mp) char stdout_buf[200]; while (1) { memset(stdout_buf, 0, sizeof(stdout_buf)); r = get_string_from_pipe(mp->stdout, stdout_buf, sizeof(stdout_buf) - 1); Loading