浏览代码

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 年前
父节点
当前提交
f8a4999e40
共有 2 个文件被更改,包括 2 次插入1 次删除
  1. +1
    -0
      btpd/net.c
  2. +1
    -1
      btpd/net.h

+ 1
- 0
btpd/net.c 查看文件

@@ -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 查看文件

@@ -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
正在加载...
取消
保存