Skip to content
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

Fix oppushdata overflow bug #22

Merged
merged 3 commits into from
May 6, 2021
Merged

Fix oppushdata overflow bug #22

merged 3 commits into from
May 6, 2021

Conversation

caevv
Copy link
Contributor

@caevv caevv commented May 5, 2021

fix panic:
panic: runtime error: slice bounds out of range [3:2]

@codecov-commenter
Copy link

codecov-commenter commented May 5, 2021

Codecov Report

Merging #22 (a279d95) into master (e5e01aa) will decrease coverage by 2.39%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
- Coverage   78.28%   75.88%   -2.40%     
==========================================
  Files          16       16              
  Lines        1165      846     -319     
==========================================
- Hits          912      642     -270     
+ Misses        166      140      -26     
+ Partials       87       64      -23     
Impacted Files Coverage Δ
bscript/oppushdata.go 65.27% <0.00%> (ø)
internalsigner.go 61.29% <0.00%> (-24.01%) ⬇️
output.go 82.95% <0.00%> (-6.62%) ⬇️
tx.go 76.08% <0.00%> (-1.50%) ⬇️
signaturehash.go 77.77% <0.00%> (-0.39%) ⬇️
input.go 82.25% <0.00%> (+4.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5e01aa...a279d95. Read the comment docs.

@jadwahab
Copy link
Member

jadwahab commented May 5, 2021

Thanks for raising this @caevv. From an initial glance, I don't see how your PR changes fix the issue raised. Can you give us some more information regarding the panic situation? Input values so that we can reproduce the panic error you mention above would be great.

@caevv
Copy link
Contributor Author

caevv commented May 5, 2021

Thanks for raising this @caevv. From an initial glance, I don't see how your PR changes fix the issue raised. Can you give us some more information regarding the panic situation? Input values so that we can reproduce the panic error you mention above would be great.

You are right, there is more to it than that. The size of that l seems to be bigger than what uint16 can hold. (65535 for this example)

I'm using this with tx id: cba1d7e24dd31cb9cb5d029b825b081e64c65d631ee8a71653a01210da7e1034

	for _, out := range tx.Outputs {
		_, err := out.LockingScript.ToASM()
		if err != nil {
			fmt.Println(err)
		}
	}

panics on LockingScript.ToASM:

panic: runtime error: slice bounds out of range [3:2]

goroutine 1 [running]:
github.com/libsv/go-bt/bscript.DecodeParts(0xc00039214e, 0x1001c, 0x11eb2, 0x0, 0x0, 0x0, 0x0, 0x0)
        .../github.com/libsv/go-bt/bscript/oppushdata.go:109 +0x1054
github.com/libsv/go-bt/bscript.(*Script).ToASM(0xc00000e240, 0x0, 0x0, 0x0, 0x0)
        .../github.com/libsv/go-bt/bscript/script.go:200 +0xaa

@ordishs
Copy link
Collaborator

ordishs commented May 6, 2021 via email

@theflyingcodr
Copy link
Contributor

Good point @ordishs; I think the other approach is probably best then.

Would you be able to add a unit test in with the failing script to show that the fix works and to ensure if this code is changed in future that the test catches it.

@theflyingcodr theflyingcodr added the bug Something isn't working label May 6, 2021
@jadwahab jadwahab changed the title Update oppushdata Fix oppushdata overflow bug May 6, 2021
@jadwahab jadwahab merged commit 711c7a8 into libsv:master May 6, 2021
jadwahab pushed a commit that referenced this pull request May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants