Re: BUG REPORT tin 1.9.5 release 20091201 ("Rieclachan") [UNIX]
Dennis Preiser <[email protected]> Thu, 10 Dec 2009 20:34:02 +0100
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
On 09.12.2009, at 17:30, Urs Janßen wrote: > tin crashes when viewing > <[email protected]> > in news.software.readers while building the page header (inside the > References). [...] > the headers of mentioned article: > References: <[email protected]> > <[email protected]> > <[email protected]> > <[email protected]> > <[email protected]> In cook.c:(w)expand_ctrl_chars() we resize the buffer too late. At least one expanded TAB (+ \0) should fit into the remaining space. Another issue: If an header exceeds LEN (1024) after expanding, only the first 1024 chars are visible. cook.c:cook_article() uses LEN in put_cooked(). The patch below changes this too (use the real length). diff -urp tin-1.9.5/src/cook.c tin-1.9.5_r1/src/cook.c --- tin-1.9.5/src/cook.c 2009-12-01 15:15:28.000000000 +0100 +++ tin-1.9.5_r1/src/cook.c 2009-12-10 19:57:34.000000000 +0100 @@ -111,7 +111,7 @@ expand_ctrl_chars( c = (unsigned char *) *line; while (*c) { - if (i > curr_len - 3) { + if (i > curr_len - (lcook_width + 1)) { curr_len <<= 1; buf = my_realloc(buf, curr_len); } @@ -158,14 +158,15 @@ wexpand_ctrl_chars( wc = *wline; while (*wc) { - if (i > cur_len - 3) { + if (i > cur_len - (lcook_width + 1)) { cur_len <<= 1; wbuf = my_realloc(wbuf, cur_len * sizeof(wchar_t)); } @@ -848,7 +849,7 @@ cook_article( #endif /* MULTIBYTE_ABLE && !NO_LOCALE */ header_put = TRUE; expand_ctrl_chars(&l, &i, tabwidth); - put_cooked(LEN, wrap_lines, C_HEADER, "%s", l); + put_cooked(i, wrap_lines, C_HEADER, "%s", l); free(l); } } Last but not least a question: in cook.c:(w)expand_ctrl_chars() we use the following code to compute j: | if (*wc == '\n') | ln = i + 1; | if (*wc == '\t') { /* expand_tabs */ | j = i + lcook_width - ((i - ln) % lcook_width); | for (; i < j; i++) | wbuf[i] = ' '; This gives wrong results when a line contains several TABs (but no newlines). I think it is sufficient to use only j = i + lcook_width here (no need for ln), but I'm not entirely shure whether this breaks anything else or not. Dennis