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

Panic on deserialising a short message #159

Closed
peterebden opened this issue Jan 28, 2022 · 2 comments
Closed

Panic on deserialising a short message #159

peterebden opened this issue Jan 28, 2022 · 2 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@peterebden
Copy link

Message.Unpack() panics if given an input shorter than 4 bytes:

	t.Run("Test unpacking an empty input", func(t *testing.T) {
		message := NewMessage(spec)
		message.Unpack(nil)
	})
--- FAIL: TestMessage (0.00s)
    --- FAIL: TestMessage/Test_unpacking_an_empty_input (0.00s)
panic: runtime error: slice bounds out of range [:4] with capacity 3 [recovered]
	panic: runtime error: slice bounds out of range [:4] with capacity 3

goroutine 25 [running]:
testing.tRunner.func1.2({0x6130a0, 0xc0000ae438})
	testing/testing.go:1360 +0x24e
testing.tRunner.func1()
	testing/testing.go:1363 +0x39f
panic({0x6130a0, 0xc0000ae438})
	runtime/panic.go:838 +0x207
github.com/moov-io/iso8583/encoding.asciiEncoder.Decode({}, {0xc0001310f8?, 0x0?, 0x7ff419b0a5e0?}, 0x8?)
	github.com/moov-io/iso8583/encoding/ascii.go:23 +0x145
github.com/moov-io/iso8583/field.(*String).Unpack(0xc0000e5420, {0xc0001310f8, 0x3, 0x3})
	github.com/moov-io/iso8583/field/string.go:84 +0xf3
github.com/moov-io/iso8583.(*Message).Unpack(0xc000098fc0, {0xc0001310f8, 0x3, 0x3})
	github.com/moov-io/iso8583/message.go:186 +0x256
github.com/moov-io/iso8583.TestMessage.func4(0x0?)
	github.com/moov-io/iso8583/message_test.go:189 +0x4c
testing.tRunner(0xc000164ea0, 0xc000097740)
	testing/testing.go:1410 +0x102
created by testing.(*T).Run
	testing/testing.go:1457 +0x35f
exit status 2
FAIL	github.com/moov-io/iso8583	0.010s
@alovak alovak added good first issue Good for newcomers help wanted Extra attention is needed labels Feb 8, 2022
@alovak
Copy link
Contributor

alovak commented Feb 9, 2022

@peterebden please check #161 it should solve the issue. Thanks for reporting it!

@alovak alovak closed this as completed Feb 9, 2022
@peterebden
Copy link
Author

Thank you for fixing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants