Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

fix buffer size check #44

Merged
merged 1 commit into from
Apr 28, 2019
Merged

fix buffer size check #44

merged 1 commit into from
Apr 28, 2019

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Apr 28, 2019

Trying to trace the source of the bug in libp2p/go-mplex#43, I run across this erroneous check.
I don't think that's the source of the bug, but it's still a bug as it can overwrite the buffer past the slice boundary designated by the caller and perform an oversize read.
It also has similar characteristics to what we observe (an oversize read) so there is a (slim) hope that it will fix the issue.

@vyzo vyzo requested a review from Stebalien April 28, 2019 14:22
@ghost ghost assigned vyzo Apr 28, 2019
@ghost ghost added the in progress label Apr 28, 2019
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Great catch! This is almost certainly the issue. On line 181, we reslice using fullLen. This works because it's still <= the capacity. However, it means that we read more than was asked into this resliced buffer and return the actual size read (which is greater than the size of the original buffer).

@Stebalien Stebalien merged commit 3175340 into master Apr 28, 2019
@ghost ghost removed the in progress label Apr 28, 2019
@Stebalien Stebalien deleted the fix/oversize-read branch April 28, 2019 19:35
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.

2 participants