Browse Source

The generic reader didn't have a buffer that was large enough to

save uncomplete messages. I had forgotten about the four bytes of
message length preceding the message. A buffer overflow could occur
because of this. Ouch!
master
Richard Nyberg 19 years ago
parent
commit
f8a4999e40
2 changed files with 2 additions and 1 deletions
  1. +1
    -0
      btpd/net.c
  2. +1
    -1
      btpd/net.h

+ 1
- 0
btpd/net.c View File

@@ -766,6 +766,7 @@ net_generic_read(struct peer *p, unsigned long rmax)
} }
if (off != len) { if (off != len) {
gr->iob.buf_off = len - off; gr->iob.buf_off = len - off;
assert(gr->iob.buf_off <= gr->iob.buf_len);
bcopy(buf + off, gr->iob.buf, gr->iob.buf_off); bcopy(buf + off, gr->iob.buf, gr->iob.buf_off);
} }
event_add(&p->in_ev, NULL); event_add(&p->in_ev, NULL);


+ 1
- 1
btpd/net.h View File

@@ -65,7 +65,7 @@ struct handshake {
char _io_buf[SHAKE_LEN]; char _io_buf[SHAKE_LEN];
}; };


#define MAX_INPUT_LEFT 12
#define MAX_INPUT_LEFT 16


struct generic_reader { struct generic_reader {
struct input_reader rd; struct input_reader rd;


Loading…
Cancel
Save