9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] bug in ape?
@ 2007-12-18 20:22 ron minnich
  2007-12-19  2:51 ` sqweek
  0 siblings, 1 reply; 4+ messages in thread
From: ron minnich @ 2007-12-18 20:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

The ssh2 always fails with copious data. I.e. lots of data comes in,
and the proc reading from the socket at some point fails.

I see this go by:
pread(4, 0x06000508, 8192, 4294967295)
	return value: 7520
	data: 0x06000508, 7520

Note the offset is x508, and we read 7520 bytes, which, if the buffer
is 8k, is an overrun.

The ape code is this:
static void
_copyproc(int fd, Muxbuf *b)
{
	unsigned char *e;
	int n;
	int nzeros;

	e = &b->data[PERFDMAX];
	for(;;) {
		/* make sure there's room */
		lock(&mux->lock);
		if(e - b->putnext < READMAX) {
			if(b->getnext == b->putnext) {
				b->getnext = b->putnext = b->data;
				unlock(&mux->lock);
			} else {
				/* sleep until there's room */
				b->roomwait = 1;
				unlock(&mux->lock);
				_RENDEZVOUS((unsigned long)&b->roomwait, 0);
			}
		} else
			unlock(&mux->lock);
		/*
		 * A Zero-length _READ might mean a zero-length write
		 * happened, or it might mean eof; try several times to
		 * disambiguate (posix read() discards 0-length messages)
		 */
		nzeros = 0;
		do {
			n = _READ(fd, b->putnext, READMAX); <<<<<<<<<============= this line
			if(b->fd == -1) {
				_exit(0);		/* we've been closed */
			}
		} while(n == 0 && ++nzeros < 3);
		lock(&mux->lock);

note the _READ above. It always calls with READMAX. I don't know yet
what putnext can be (in range), but this is a data point. I am posting
this as there may be someone who has seen it before.

ron


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-19 21:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-18 20:22 [9fans] bug in ape? ron minnich
2007-12-19  2:51 ` sqweek
2007-12-19  4:36   ` ron minnich
2007-12-19 21:23     ` cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).