This patch eliminates a line length limit in pop3resp. It changes pop3resp to use Brdstr rather than Brdline. The patched pop3resp still takes care of memory management for its callers: A line is freed when the next line is read. The limit causes upas/fs to blow up with "unexpected eof" and "unexpected end of conversation" when unreasonable messages exist on a POP server. Notes: Mon Jan 31 20:26:12 EST 2005 swasey I had forgotten that free(0) is a noop. I suggest you replace "if(l){ free(l); l = s; }" in the patch with "free(l); l = s;". Wed Feb 2 10:33:17 EST 2005 rsc This assumes that there is only one POP3 mail box open. Wed Feb 2 10:36:04 EST 2005 rsc Also, you didn't change Blinelen to strlen, suggesting that you've not actually tried this on servers with such enormous lines. Do they actually exist? Reference: /n/sources/patch/applied/pop3resp Date: Wed Feb 2 16:37:38 CET 2005 Reviewed-by: rsc --- /sys/src/cmd/upas/fs/pop3.c Wed Feb 2 16:37:38 2005 +++ /sys/src/cmd/upas/fs/pop3.c Wed Feb 2 16:37:38 2005 @@ -80,9 +80,10 @@ { char *s; char *p; + static char *l = nil; alarm(60*1000); - if((s = Brdline(&pop->bin, '\n')) == nil){ + if((s = Brdstr(&pop->bin, '\n', 0)) == nil){ close(pop->fd); pop->fd = -1; alarm(0); @@ -90,6 +91,10 @@ } alarm(0); + if(l){ + free(l); + l = s; + } p = s+Blinelen(&pop->bin)-1; while(p >= s && (*p == '\r' || *p == '\n')) *p-- = '\0';