Merge pull request #2 from digitalocean/fix-buffer-overwrite
fixes response overwrite bug
This commit is contained in:
commit
fc88e157af
6
rpc.go
6
rpc.go
@ -195,16 +195,12 @@ func (l *Libvirt) listen() {
|
|||||||
// payload: packet length minus what was previously read
|
// payload: packet length minus what was previously read
|
||||||
size := int(length) - (constants.PacketLengthSize + constants.HeaderSize)
|
size := int(length) - (constants.PacketLengthSize + constants.HeaderSize)
|
||||||
buf := make([]byte, size)
|
buf := make([]byte, size)
|
||||||
for n := 0; n < size; {
|
_, err = io.ReadFull(l.r, buf)
|
||||||
nn, err := l.r.Read(buf)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// invalid packet
|
// invalid packet
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
n += nn
|
|
||||||
}
|
|
||||||
|
|
||||||
// route response to caller
|
// route response to caller
|
||||||
l.route(h, buf)
|
l.route(h, buf)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user