Commit Graph

6 Commits

Author SHA1 Message Date
Anton Kaliaev d94e312673 add MarshalJSON and UnmarshalJSON to BitArray (#200)
See CHANGELOG
2018-04-23 00:16:05 -07:00
Emmanuel T Odeke b1c9b82531 common: NewBitArray never crashes on negatives (#170)
Fixes #169
Fixes https://github.com/tendermint/tendermint/issues/1322

The previous code was very trusting assuming that
rational actors will use this code. However, Byzantine
actors don't care and in the case of the linked issue
negative lengths can be sent to this code unfettered
having been received from a peer.

This code is essentially just a sign change from
`==`
to
`<=`

and we've gutted out that attack by being more defensive.
2018-03-18 15:17:11 +04:00
Emmanuel Odeke 763dc21393
common/BitArray: reduce fragility with methods
Fixes https://github.com/tendermint/tmlibs/issues/145
Fixes https://github.com/tendermint/tmlibs/issues/146

The code in here has been fragile when it comes to nil
but these edge cases were never tested, although they've
showed up in the wild and were only noticed because
the reporter actually read the logs otherwise
we'd have never known.

This changes covers some of these cases and adds some tests.
2018-02-06 01:12:24 -08:00
Emmanuel Odeke 85be26c675
common: BitArray: feedback from @adrianbrink to simplify tests 2018-01-28 22:02:51 -07:00
Emmanuel Odeke 84afef20f5
common: fix BitArray.Update to avoid nil dereference
Update previously only checked that the receiver was
non-nil but didn't check that the input parameter to update
"o" was non-nil causing a nil dereference in cases such as
fe632ea32a/consensus/reactor.go (L306)

Fixes https://github.com/tendermint/tendermint/issues/1169
2018-01-28 10:39:42 -07:00
Ethan Buchman 356657a37b move all files to common/ to begin repo merge 2017-04-18 16:33:22 -04:00