another crash due to assuming that the page size is relatively small. also, do raw processing after binary processing. Reference: /n/patches.lsub.org/patch/telseg Date: Wed Jul 11 22:10:59 CES 2012 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/ip/telnet.c Thu Apr 12 12:25:52 2012 +++ /sys/src/cmd/ip/telnet.c Wed Jul 11 20:59:21 2012 @@ -33,7 +33,7 @@ int echochange(Biobuf*, int); int termsub(Biobuf*, uchar*, int); int xlocsub(Biobuf*, uchar*, int); -void* share(ulong); +void* share(usize); static int islikeatty(int); @@ -564,7 +564,7 @@ * create a shared segment. */ void* -share(ulong len) +share(usize len) { uchar *vastart; --- /sys/src/cmd/ip/telnetd.c Thu Apr 12 12:25:52 2012 +++ /sys/src/cmd/ip/telnetd.c Wed Jul 11 20:56:05 2012 @@ -43,7 +43,7 @@ int xlocsub(Biobuf*, uchar*, int); int challuser(char*); int noworldlogin(char*); -void* share(ulong); +void* share(usize); int doauth(char*); #define TELNETLOG "telnet" @@ -128,6 +128,7 @@ /* setup default telnet options */ if(!noproto){ send3(1, Iac, Will, opt[Echo].code); + send3(1, Iac, Do, opt[Line].code); send3(1, Iac, Do, opt[Term].code); send3(1, Iac, Do, opt[Xloc].code); } @@ -398,12 +399,6 @@ } else crnl = 0; - /* raw processing (each character terminates */ - if(cons->raw){ - *bp++ = c; - break; - } - /* in binary mode, there are no control characters */ if(opt[Binary].local){ if(opt[Echo].local) @@ -411,6 +406,15 @@ *bp++ = c; continue; } + + /* raw processing (each character terminates) */ + if(cons->raw){ + if(c == 0x00) + if(!noproto) /* telnet ignores nulls */ + continue; + *bp++ = c; + break; + } /* cooked processing */ switch(c){ @@ -541,21 +545,16 @@ } /* - * create a shared segment. Make is start 2 meg higher than the current - * end of process memory. + * create a shared segment. */ void* -share(ulong len) +share(usize len) { uchar *vastart; - vastart = sbrk(0); - if(vastart == (void*)-1) - return 0; - vastart += 2*1024*1024; - - if(segattach(0, "shared", vastart, len) == (void*)-1) - return 0; + vastart = segattach(0, "shared", 0, len); + if(vastart== (void*)-1) + sysfatal("segattach: %r"); return vastart; }