win: handle malformed runes better [rsc] --rw-rw-r-- M 940585 glenda sys 2743 Apr 16 09:04 acme/bin/source/win/fs.c /n/sourcesdump/2006/0416/plan9/acme/bin/source/win/fs.c:46,52 - /n/sourcesdump/2006/0417/plan9/acme/bin/source/win/fs.c:46,52 { static Event *e[4]; Event *ep; - int i, j, nb, wid, pid; + int i, j, ei, nb, wid, pid; Rune rune; char *s; char tmp[UTFmax], *t; /n/sourcesdump/2006/0416/plan9/acme/bin/source/win/fs.c:97,104 - /n/sourcesdump/2006/0417/plan9/acme/bin/source/win/fs.c:97,105 nb = j; t[j] = '\0'; } + ei = nb>8192? 8192 : nb; /* process bytes into runes, transferring terminal partial runes into next buffer */ - for(i=j=0; ib+i, nb-i); i+=wid,j++) + for(i=j=0; ib+i, ei-i); i+=wid,j++) wid = chartorune(&rune, ep->b+i); memmove(tmp, ep->b+i, nb-i); partial = nb-i; [rsc] --rw-rw-r-- M 940585 glenda sys 12432 Apr 16 09:04 acme/bin/source/win/main.c /n/sourcesdump/2006/0416/plan9/acme/bin/source/win/main.c:436,442 - /n/sourcesdump/2006/0417/plan9/acme/bin/source/win/main.c:436,442 sprint(tmp, "#%lud", hostpt); winsetaddr(w, tmp, 0); write(w->data, e->b, e->nb); - pendingS += utfnlen(e->b, e->nb); + pendingS += e->nr; break; case 'E': /* write to tag or body; body happens due to sendit */