Merge pull request #2 from digitalocean/fix-buffer-overwrite
fixes response overwrite bug
This commit is contained in:
commit
fc88e157af
12
rpc.go
12
rpc.go
@ -195,14 +195,10 @@ 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)
|
||||
if err != nil {
|
||||
// invalid packet
|
||||
continue
|
||||
}
|
||||
|
||||
n += nn
|
||||
_, err = io.ReadFull(l.r, buf)
|
||||
if err != nil {
|
||||
// invalid packet
|
||||
continue
|
||||
}
|
||||
|
||||
// route response to caller
|
||||
|
Loading…
Reference in New Issue
Block a user