Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

qemu/qmp: fix readLoop() reuse scanner.Bytes() underlying array problem #89

Merged
merged 1 commit into from
Mar 13, 2019

Conversation

flyflypeng
Copy link
Contributor

Since []byte channel type transfer slice info(include slice underlying array pointer, len, cap)
between channel sender and receiver. scanner.Bytes() function returned slice's underlying array
may point to data that will be overwritten by a subsequent call to Scan(reference from:
https://golang.org/pkg/bufio/#Scanner.Bytes), which may make consecutive scan() call write the
read data into the same underlying array which causes receiver read mixed data,so we need to
copy line to new allocated space and then send to channel receiver to solve this problem.

Fixes: #88

Signed-off-by: jiangpengfei jiangpengfei9@huawei.com

Copy link

@devimc devimc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @woshijpf , good catch! lgtm

Copy link
Contributor

@markdryan markdryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this bug has been present since the very first commit of govmm I think. Nice catch @woshijpf.

@markdryan
Copy link
Contributor

We're just waiting on travis here which seems to be a bit slow. As soon as the travis builds pass we can merge.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 79.277% when pulling 5712b11 on woshijpf:master into b48780f on intel:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 79.277% when pulling 5712b11 on woshijpf:master into b48780f on intel:master.

@devimc devimc merged commit 4963fb5 into kata-containers:master Mar 13, 2019
Since []byte channel type transfer slice info(include slice underlying array pointer, len, cap)
between channel sender and receiver. scanner.Bytes() function returned slice's underlying array
may point to data that will be overwritten by a subsequent call to Scan(reference from:
https://golang.org/pkg/bufio/#Scanner.Bytes), which may make consecutive scan() call write the
read data into the same underlying array which causes receiver read mixed data,so we need to
copy line to new allocated space and then send to channel receiver to solve this problem.

Fixes: kata-containers#88

Signed-off-by: jiangpengfei <jiangpengfei9@huawei.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants