-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIXED] Make sure to use byte slice to receive proper copy #59
Conversation
…ublic key is being used. Signed-off-by: Derek Collison <[email protected]>
Pull Request Test Coverage Report for Build 6598807631
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed. I think it's fine to apply as a comprehension change, but I think the logic before was correct.
Notably, the prior state was that the input was an array, not a slice, and that the [:]
did not force a capacity limit and thus a reallocation.
https://go.dev/play/p/c3N6VcA-L1Q
See that test code, and how using y := x[:]
before copying into y
also updates x
.
So I don't think there's a security issue here. But it's good to be clear, so approving the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so the actual problem is caused by missing that Go is pass-by-value and when you're passing in an array, you get a copy of the array, so the passing in of the slice over the array results in the called function getting a new slice value over the same array, and being able to modify the caller.
Please update the title before merge, because "Make sure to use byte slice to receive proper copy" is ... the opposite of true? You're using a byte slice so that you're not getting a copy of the underlaying data and can instead modify the original. |
The title I believe is correct, we would copy the byte array on the stack, so when we copied it into that copy, it was lost. Using the slice we do get the data correctly when we return. |
Empty public key was being used.
Huge thanks for the report from @tinou98!
Signed-off-by: Derek Collison [email protected]