From: Andre Noll Date: Mon, 18 Mar 2013 19:13:35 +0000 (+0100) Subject: gui: Discard overlong input lines. X-Git-Tag: v0.4.13~33^2~11 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=a44fa6f118540d47cc575cbc62d22a6e4bb784e9;p=paraslash.git gui: Discard overlong input lines. If an external command produces output without newlines, the current code ends up calling read_nonblock() with a buffer size of zero which triggers the assertion in readv_nonblock(). Increase the output buffer to 32K and fix the problem by simply discarding all input if the input buffer is full and contains no newline character. A better fix would be to discard everything until the next newline character is read, but this requires more work, so let's go with this simple fix for now. --- diff --git a/gui.c b/gui.c index a4ee7275..728fb9b7 100644 --- a/gui.c +++ b/gui.c @@ -951,7 +951,7 @@ static int open_stat_pipe(void) return ret; } -#define COMMAND_BUF_SIZE 4096 +#define COMMAND_BUF_SIZE 32768 /* * This is the core select loop. Besides the (internal) signal @@ -1023,6 +1023,10 @@ repeat: if (command_fds[!i] < 0) /* both fds closed */ return 0; } + if (cbo[i] == COMMAND_BUF_SIZE - 1) { + PARA_NOTICE_LOG("discarding overlong line"); + cbo[i] = 0; + } } } ret = read_stat_pipe(&rfds);