actually limit snarf to SNARFSIZE rather than confusing the sam protocol. Reference: /n/sources/patch/applied/sam-snarf-sz Date: Fri Feb 10 19:01:32 CET 2012 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/samterm/mesg.c Fri Feb 10 19:01:15 2012 +++ /sys/src/cmd/samterm/mesg.c Fri Feb 10 19:01:14 2012 @@ -33,9 +33,9 @@ rcv(void) { int c; - static state = 0; - static count = 0; - static i = 0; + static int state = 0; + static int count = 0; + static int i = 0; static int errs = 0; while((c=rcvchar()) != -1) @@ -645,10 +645,17 @@ if(n >= 0){ if(!s1) n = 0; - s1 = realloc(s1, n+1); - if (!s1) - panic("realloc"); - s1[n] = 0; + if(n > SNARFSIZE){ + s1 = strdup(""); + if (!s1) + panic("strdup"); + n = strlen(s1); + }else{ + s1 = realloc(s1, n+1); + if (!s1) + panic("realloc"); + s1[n] = 0; + } snarflen = n; outTs(Tsetsnarf, n); if(n>0 && write(1, s1, n)!=n)