- 16 Feb, 2017 2 commits
-
-
Kamil Kisiel authored
-
Kamil Kisiel authored
encoder: More unexpected EOF handling
-
- 15 Feb, 2017 2 commits
-
-
Kirill Smelkov authored
Continuing 995fce81 I've decided to rework unexpected EOF testing to run on truncated versions of all inputs we already have. This uncovered the following: - if an individual op decoder returns err=io.EOF - this is unexpected and should be turned into io.ErrUnexpectedEOF. If we do not do it shows as e.g. ogorek_test.go:91: int: no ErrUnexpectedEOF on [:1] truncated stream: v = <nil> err = &errors.errorString{s:"EOF"} - there was a potential buffer overrun panic in loadString - the code there did not have proper check for line rest length after initial ". The panic looks like this: --- FAIL: TestDecode (0.00s) panic: runtime error: slice bounds out of range [recovered] panic: runtime error: slice bounds out of range goroutine 7 [running]: testing.tRunner.func1(0xc4200725b0) /home/kirr/src/tools/go/go/src/testing/testing.go:624 +0x267 panic(0x5368c0, 0x603020) /home/kirr/src/tools/go/go/src/runtime/panic.go:489 +0x26e github.com/kisielk/og-rek.(*Decoder).loadString(0xc420063428, 0xc42000e153, 0x0) /home/kirr/src/wendelin/neo/g.neo/src/github.com/kisielk/og-rek/ogorek.go:478 +0x22d github.com/kisielk/og-rek.Decoder.Decode(0xc42012fbc0, 0x6248e8, 0x0, 0x0, 0xc42013ac60, 0x0, 0x0, 0x5f2480, 0xc42000e150) /home/kirr/src/wendelin/neo/g.neo/src/github.com/kisielk/og-rek/ogorek.go:166 +0xa83 github.com/kisielk/og-rek.TestDecode(0xc4200725b0) /home/kirr/src/wendelin/neo/g.neo/src/github.com/kisielk/og-rek/ogorek_test.go:89 +0x26c7 testing.tRunner(0xc4200725b0, 0x567618) /home/kirr/src/tools/go/go/src/testing/testing.go:659 +0x98 created by testing.(*T).Run /home/kirr/src/tools/go/go/src/testing/testing.go:701 +0x2df exit status 2 and can be triggered by single-character " input. - we also turn what was previously an "insecure string" into unexpected EOF. The reason here is: code could not find " in the end of the string. This can be for 2 reasons: 1. EOF was reached, or 2. EOL (end of line) was reached unfortunately since we are currently using bufio.Buffer.ReadLine() which does not indicate whether EOL was there or not and strips it from result, we cannot distinguish above cases and properly report "insecure string" in 2 case. However unexpected EOF even for #2 seems a bit reasonable, so I think the change should be ok.
-
Kirill Smelkov authored
This is explicitly stated in bytes.Buffer documentation and is already relyed by ogórek in another place: https://github.com/kisielk/og-rek/blob/c7dbf2e4/ogorek.go#L524
-
- 14 Feb, 2017 5 commits
-
-
Kamil Kisiel authored
-
Kamil Kisiel authored
-
Kamil Kisiel authored
Misc fixes (error + opStop handling)
-
Kirill Smelkov authored
io.EOF handling was already there in instructions decoding loop, but it was simply breaking out of the loop and in the end decode unconditionally was trying to pop top element from stack, and since stack is empty panicked. E.g. for "" input this way: --- FAIL: TestDecode (0.00s) panic: runtime error: index out of range [recovered] panic: runtime error: index out of range goroutine 20 [running]: testing.tRunner.func1(0xc4200765b0) /home/kirr/src/tools/go/go/src/testing/testing.go:624 +0x267 panic(0x5368c0, 0x603010) /home/kirr/src/tools/go/go/src/runtime/panic.go:489 +0x26e github.com/kisielk/og-rek.Decoder.Decode(0xc4200ea5a0, 0x624908, 0x0, 0x0, 0xc4200e6b10, 0x52a180, 0xc4200ee308, 0x0, 0x0) /home/kirr/src/wendelin/neo/g.neo/src/github.com/kisielk/og-rek/ogorek.go:250 +0x4bb github.com/kisielk/og-rek.TestDecode(0xc4200765b0) /home/kirr/src/wendelin/neo/g.neo/src/github.com/kisielk/og-rek/ogorek_test.go:80 +0x232f testing.tRunner(0xc4200765b0, 0x567648) /home/kirr/src/tools/go/go/src/testing/testing.go:659 +0x98 created by testing.(*T).Run /home/kirr/src/tools/go/go/src/testing/testing.go:701 +0x2df exit status 2 Fix it via reworking EOF handling: - if we see EOF and no instructions was decoded so far - just return it to the caller - if we see EOF in the middle of the stream - as valid pickle streams end with Stop opcode - it is unexpected EOF - return it as such. A couple of tests had to be adjusted in TestDecode - as input there was not a valid pickle - not ending with "." (which python pickle decoder also does not decode at all).
-
Kirill Smelkov authored
There was a break already on a `case opStop:` but break inside switch only breaks out of this switch, not outer construct - looks like it was a thinko. So on opStop let's explicitly break out of instruction processing loop. If we do not do so on e.g "I5\n.I7\n.N." input first call to .Decode() returns None (from N.), not 5 and second call to Decode() panics (for this see next patch).
-
- 13 Feb, 2017 1 commit
-
-
Kirill Smelkov authored
Previously errors from underlying .encode() were ignored completely and not returned to callers.
-
- 04 Jan, 2016 1 commit
-
-
Kamil Kisiel authored
Implement opMemoize/opShortBinUnicode/opFrame from 'Protocol 4'
-
- 01 Jan, 2016 1 commit
-
-
Sean DuBois authored
-
- 30 Dec, 2015 3 commits
-
-
Sean DuBois authored
-
Sean DuBois authored
-
Sean DuBois authored
-
- 23 Jun, 2015 4 commits
-
-
Kamil Kisiel authored
-
Kamil Kisiel authored
-
https://github.com/CodeRushing/og-rekKamil Kisiel authored
Merge branch 'feature/FixReadLineBug' of https://github.com/CodeRushing/og-rek into CodeRushing-feature/FixReadLineBug
-
liaoqiang authored
-
- 22 Jun, 2015 1 commit
-
-
Kamil Kisiel authored
fix when the first char is \, it cause UnquoteChar to return syntax e…
-
- 19 Jun, 2015 3 commits
- 18 Jun, 2015 2 commits
- 12 Jun, 2015 1 commit
-
-
Kamil Kisiel authored
fix for buffer limit in loading string
-
- 28 Jan, 2015 1 commit
-
-
harshad authored
-
- 20 Oct, 2014 3 commits
-
-
Kamil Kisiel authored
-
-
Kamil Kisiel authored
Handle write and read errors.
-
- 15 Oct, 2014 2 commits
-
-
Larz Conwell authored
This makes it simpler to handle errors in code importing this package.
-
Larz Conwell authored
-
- 30 Sep, 2014 3 commits
-
-
Kamil Kisiel authored
Implement r opcode LONG_BINPUT
-
Sean DuBois authored
-
Sean DuBois authored
-
- 18 Sep, 2014 1 commit
-
-
Kamil Kisiel authored
Fix struct encoding
-
- 17 Sep, 2014 1 commit
-
-
Damian Gryski authored
There was accidentally an extra empty dict. Also, reduce the scope of a local variable.
-
- 24 Jul, 2014 2 commits
-
-
Kamil Kisiel authored
Changed the filenames ogórek.go and ogórek_test.go to use the precomposed Latin Small Letter O With Acute.
-
tmedwards authored
Changed the filenames for `ogórek.go` and `ogórek_test.go` use the precomposed Latin Small Letter O With Acute.
-
- 11 Jul, 2014 1 commit
-
-
Kamil Kisiel authored
printf verb fix
-