Matt Joiner
6156aebf71
Limit decoded bencode string lengths to 32 bits
...
Found in fuzzing
2021-09-29 16:56:01 +10:00
Matt Joiner
10ecd4390a
Fix parsing of strings that don't fit in memory
2021-09-29 12:11:58 +10:00
Matt Joiner
a9aec0bb79
Simplify bencode.Decoder.parseStringInterface
2021-09-29 09:50:01 +10:00
YenForYang
37455d3c6b
bencode: optimize `(*Decoder).parseStringInterface()` ( #659 )
2021-09-29 09:30:35 +10:00
YenForYang
d43769dc15
bencode: Simplify `(*Decoder).parseListInterface()` ( #656 )
...
Preserve as much type as possible (it'll be converted to an `interface{}` anyway, but we can return `[]interface{}` instead of `{}interface` here).
2021-09-18 12:42:20 +10:00
Bora M. Alper
16176b762e
Add linter CI ( #542 )
...
* Add linter CI
Signed-off-by: Bora M. Alper <bora@boramalper.org>
* Make gosec CI ignore SHA1 and upload sarif
Signed-off-by: Bora M. Alper <bora@boramalper.org>
* Fix formatting of source files
Signed-off-by: Bora M. Alper <bora@boramalper.org>
* Make go vet ignore unkeyed composite literals and fix other warnings
Signed-off-by: Bora M. Alper <bora@boramalper.org>
* Make staticcheck ignore unused methods and fix other warnings
Signed-off-by: Bora M. Alper <bora@boramalper.org>
* Use golangci-lint
Signed-off-by: Bora M. Alper <bora@boramalper.org>
2021-08-16 11:11:31 +10:00
Matt Joiner
901a8b1b36
Don't panic on int parse failures
...
This means for UnmarshalTypeErrors we now include context. There are still some other error types remaining that are thrown up via panic.
2021-08-12 13:46:02 +10:00
Matt Joiner
a76fad32eb
Fix panic unmarshalling bencode dict into unsupported type
2021-08-12 12:16:53 +10:00
Matt Joiner
047cdbae0d
bencode: Improve support for embedded structs
2021-06-07 13:01:40 +10:00
Matt Joiner
25d2eea12d
bencode: Support anonymous embedded struct pointers
...
More to come if this line of improvement is retained.
2021-06-07 13:01:40 +10:00
Matt Joiner
259356ccd6
Rework bencode decoding so it might support embedded structs
2021-06-07 13:01:40 +10:00
Matt Joiner
95daebd067
bencode: Decode singleton lists of the expected type
...
Fixes #297 .
2019-06-13 13:07:37 +10:00
Matt Joiner
8e86f45124
Code formatting
2019-06-13 13:06:25 +10:00
Matt Joiner
d4584c2ca6
bencode: Improve UnmarshalTypeError string and list parsing error context
...
Helps with #297 .
2019-06-13 12:35:11 +10:00
Matt Joiner
fc4fab91f5
Switch to goimports import sorting
...
Used to use sortimports, but it's old, and goimports seems to have an opinion now.
2018-11-02 23:12:01 +11:00
Matt Joiner
bf5552ae3c
bencode: Remove a lot of expensive allocations
2018-07-25 13:42:28 +10:00
Matt Joiner
61d5902786
bencode: Avoid an extra getTags call
2018-07-23 11:09:42 +10:00
Matt Joiner
341501bf93
bencode: Cache struct fields
2018-07-23 10:50:58 +10:00
Matt Joiner
a4a123b04e
Don't error on bencode dicts that can't be marshalled
...
Have seen metainfo announce-lists that are lists of dicts. Possibly ignoring type errors with a tag would be smarter but I'm undecided.
2018-07-11 15:33:41 +10:00
Matt Joiner
04fa1b8d4c
Support marshalling bencode strings into byte arrays
2018-07-11 15:22:29 +10:00
Matt Joiner
1f6ba94882
Make extended handshake a struct, and move a bunch of extended stuff into peer_protocol
2018-07-10 12:20:36 +10:00
Matt Joiner
fefeef4ee9
Merge branch 'dev'
2018-06-22 17:43:51 +10:00
Matt Joiner
c5cc570e42
bencode: Remove string allocation when parsing strings
2018-06-17 16:21:04 +10:00
ia
fd7b23e527
all: gofmt
...
Run standard gofmt command on project root.
- go version go1.10.3 darwin/amd64
Signed-off-by: ia <isaac.ardis@gmail.com>
2018-06-17 15:49:58 +10:00
Matt Joiner
d7225aed03
Fix #247
2018-04-13 17:07:19 +10:00
Matt Joiner
319e57d1c6
Rework conns to/and allow multiple DHT servers
...
This will help with #229 , and IPv6 support.
2018-04-12 11:41:07 +10:00
Matt Joiner
33bfa908d2
bencode.Decoder.Decode: Don't assume panic values are type error
2018-02-13 00:55:15 +11:00
Matt Joiner
4b5203851a
bencode: Support unmarshalling strings into slices of kind Uint8
2018-02-13 00:44:05 +11:00
Matt Joiner
1f3eace72f
bencode: Add ignore_unmarshal_type_error tag
2018-01-27 14:31:46 +11:00
Matt Joiner
0e32592f78
bencode: Give more descriptive errors when failing to parse dicts
2018-01-25 21:46:50 +11:00
Matt Joiner
f060f0cb02
Comment on bencode.Decoder.Offset
2017-11-05 15:45:30 +11:00
Matt Joiner
edf2495b1f
Expose bencode.Decoder.Offset
2017-11-05 15:42:37 +11:00
Matt Joiner
7b2561cea8
bencode: More renames
2016-08-26 14:51:38 +10:00
Matt Joiner
f2cbc873a5
bencode: Rename a bunch of slug case stuff
2016-08-26 13:13:30 +10:00
Matt Joiner
ac3b40ace3
bencode: Remove private types encoder and decoder
...
Instead the functionality is exposed directly on the public types.
2016-06-15 15:00:51 +10:00
Matt Joiner
9d1a33facc
bencode: Unembed the Reader type, and minimize the interface surface
...
Want to remove some unnecessary allocations.
2016-06-15 14:51:58 +10:00
Matt Joiner
5f4fdfbd3d
bencode: Improve unknown value type error
2015-11-03 23:21:10 +11:00
Matt Joiner
28c1536daf
bencode: When decoding a dict, if the final key is missing its value, don't treat that as an error.
...
I think I'm swayed here by the robustness principle/Postel's Law.
2015-10-02 00:13:43 +10:00
Matt Joiner
8949375bd6
bencode: Decode very large integers as big.Int if they overflow int64
2015-09-20 21:08:42 +10:00
Matt Joiner
0403d4185d
bencode: Simplify parse_int
2015-08-23 17:51:24 +10:00
Matt Joiner
2ccbaa4e79
bencode: Don't allow extraneous trailing 'e's
2015-08-23 17:45:59 +10:00
Matt Joiner
4f293ca75b
Several trivial fixes
2015-06-28 16:39:04 +10:00
Matt Joiner
916c9c822a
Decoding bools has been wrong all along, always set to true
2014-12-01 23:28:47 -06:00
Matt Joiner
cdfba7a1ac
Expose SyntaxError reason with a proper error
2014-11-18 22:08:08 -06:00
Matt Joiner
7e2c384bd5
Fix buffer reuse bug and some formatting.
2014-03-20 01:54:18 +11:00
nsf
d0429086be
Add more comments to the bencode library. Implement UnmarshalerError.
2012-06-30 22:26:20 +06:00
nsf
e553531a10
Fix bugs, implement missing bits. Made a mess, can't describe properly.
2012-06-28 02:21:26 +06:00
nsf
27b64a002c
Add a couple of decode tests, fix empty slice bug.
2012-06-22 19:34:26 +06:00
nsf
57c1403300
Uncomment defer recover statement.
2012-06-20 19:34:10 +06:00
nsf
a68e4a6f5a
Initial commit.
2012-06-20 19:21:32 +06:00