Sfoglia il codice sorgente

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 20 anni fa
parent
commit
f8a4999e40
2 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  1. +1
    -0
      btpd/net.c
  2. +1
    -1
      btpd/net.h

+ 1
- 0
btpd/net.c Vedi 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 Vedi 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;


||||||
x
 
000:0
Loading…
Annulla
Salva