Merge pull request #2 from digitalocean/fix-buffer-overwrite

fixes response overwrite bug
This commit is contained in:
Ben LeMasurier 2016-06-27 13:19:02 -06:00 committed by GitHub
commit fc88e157af

6
rpc.go
View File

@ -195,16 +195,12 @@ func (l *Libvirt) listen() {
// payload: packet length minus what was previously read
size := int(length) - (constants.PacketLengthSize + constants.HeaderSize)
buf := make([]byte, size)
for n := 0; n < size; {
nn, err := l.r.Read(buf)
_, err = io.ReadFull(l.r, buf)
if err != nil {
// invalid packet
continue
}
n += nn
}
// route response to caller
l.route(h, buf)
}